]> arthur.barton.de Git - OhMyZshExtensions.git/commitdiff
Add "editor_select" plugin: Auto-detect usable editor
authorAlexander Barton <alex@barton.de>
Fri, 27 Mar 2015 15:03:03 +0000 (16:03 +0100)
committerAlexander Barton <alex@barton.de>
Fri, 27 Mar 2015 15:03:03 +0000 (16:03 +0100)
plugins/editor_select/editor_select.plugin.zsh [new file with mode: 0644]

diff --git a/plugins/editor_select/editor_select.plugin.zsh b/plugins/editor_select/editor_select.plugin.zsh
new file mode 100644 (file)
index 0000000..423b2dc
--- /dev/null
@@ -0,0 +1,24 @@
+# editor-select.plugin.zsh
+# 2015-03-27, alex@barton.de
+
+if [ -z "$EDITOR" ]; then
+       # Check "mate"
+       EDITOR=`which mate 2>/dev/null`
+       if [ $? -eq 0 ]; then
+               EDITOR="$EDITOR --wait"
+       else
+               # Check "subl"
+               EDITOR=`which subl 2>/dev/null`
+               if [ $? -eq 0 ]; then
+                       EDITOR="$EDITOR --wait"
+               else
+                       # Check "vim"
+                       EDITOR=`which vim 2>/dev/null`
+                       if [ $? -ne 0 ]; then
+                               # Check "vi"
+                               EDITOR=`which vi 2>/dev/null`
+                       fi
+               fi
+       fi
+fi
+[ -n "$EDITOR" ] && export EDITOR