summaryrefslogtreecommitdiff
path: root/v-editor.sh
blob: 09bccf5ee0bd74fb0b806a5c500655afb81ef396 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/bash

run() {
	local editor=$1; shift
	local cmd
	IFS='|' cmd=($(eval printf '%s\|' "$editor"))
	cmd+=("$@")
	"${cmd[@]}"
}

(if [ -n "$DISPLAY" ]; then run "${VISUAL:-$SELECTED_EDITOR}" "$@"
 else                       run "${EDITOR:-$SELECTED_EDITOR}" "$@"
fi) ||                      run "${ALTERNATE_EDITOR:-false}"  "$@"