summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-11-02 22:58:11 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-11-02 22:58:11 -0400
commitaf2a9f95b2c0a536bdac8093b62219e19de3f3a2 (patch)
tree0f5ea7941e9f27d24be851ba061e893cb0c18a33
parentd251e782d9fe66d64035fcc4db92dc1c98ad3190 (diff)
v-editor: this is the version I've been running
-rw-r--r--v-editor.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/v-editor.sh b/v-editor.sh
index b1a32cc..09bccf5 100644
--- a/v-editor.sh
+++ b/v-editor.sh
@@ -1,5 +1,13 @@
-#!/bin/sh
+#!/bin/bash
-(if [ -n "$DISPLAY" ]; then eval ${VISUAL:-$SELECTED_EDITOR} "$@"
- else eval ${EDITOR:-$SELECTED_EDITOR} "$@"
-fi) || eval ${ALTERNATE_EDITOR:-false} "$@"
+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}" "$@"