about summary refs log tree commit diff
path: root/profile/.profile.d/50_editor.sh
blob: b3203fb5464aa02ff85c5337e51af237cf9b1ca5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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