about summary refs log tree commit diff
path: root/profile/.profile.d/50_editor.sh
diff options
context:
space:
mode:
Diffstat (limited to 'profile/.profile.d/50_editor.sh')
-rw-r--r--profile/.profile.d/50_editor.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/profile/.profile.d/50_editor.sh b/profile/.profile.d/50_editor.sh
new file mode 100644
index 0000000..b3203fb
--- /dev/null
+++ b/profile/.profile.d/50_editor.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+_editors="
+nvim
+vim
+vi
+emacs
+nano
+ed
+"
+
+for _editor in ${_editors}; do
+	# shellcheck disable=SC2139
+	if command -v "${_editor}" >/dev/null 2>&1; then
+		export EDITOR="${_editor}" VISUAL="${_editor}"
+
+		alias e="${EDITOR}"
+		if ! command -v ed >/dev/null 2>&1; then
+			alias ed="${EDITOR}"
+		fi
+
+		break
+	fi
+done
+
+unset _editor _editors

Consider giving Nix/NixOS a try! <3