]> arthur.barton.de Git - ax-zsh.git/commitdiff
Add "editor_select" plugin to auto-configure $EDITOR variable
authorAlexander Barton <alex@barton.de>
Sat, 18 Jul 2015 01:43:18 +0000 (03:43 +0200)
committerAlexander Barton <alex@barton.de>
Sat, 18 Jul 2015 01:43:18 +0000 (03:43 +0200)
plugins/editor_select/editor_select.zprofile [new file with mode: 0644]

diff --git a/plugins/editor_select/editor_select.zprofile b/plugins/editor_select/editor_select.zprofile
new file mode 100644 (file)
index 0000000..08a0cf0
--- /dev/null
@@ -0,0 +1,23 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# editor_select.zprofile: Setup $EDITOR for the "best" available editor
+
+if [[ -z "$EDITOR" ]]; then
+       for editor in atom mate subl vim nano joe vi; do
+               if [ -n "$commands[$editor]" ]; then
+                       EDITOR="$commands[$editor]"
+                       break
+               fi
+       done
+       unset editor
+fi
+
+case "$(basename "$EDITOR")" in
+       "atom"|"mate"|"subl")
+               EDITOR="$EDITOR --wait"
+               ;;
+esac
+
+if [ -n "$EDITOR" ]; then
+       export EDITOR
+       alias zshenv="$EDITOR ~/.zshenv"
+fi