]> arthur.barton.de Git - ax-zsh.git/commitdiff
editor_select: Add support for "code", "mvim", "gvim"
authorAlexander Barton <alex@barton.de>
Sun, 12 May 2019 22:15:45 +0000 (00:15 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 12 May 2019 22:15:45 +0000 (00:15 +0200)
plugins/editor_select/editor_select.zprofile

index a5c3173d49531b6d11538c14ac1bf324238fa4e2..982d9b8e7f83837b12e3241a9206c8604a9074a1 100644 (file)
@@ -2,22 +2,34 @@
 # 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 "$DISPLAY" ]]; then
+               # X11 available, consider X11-based editors, too!
+               x11_editors="gvim"
+       fi
+
+       for editor (
+               code atom mate subl mvim
+               $x11_editors
+               vim nano joe vi
+       ); do
                if [ -n "$commands[$editor]" ]; then
                        EDITOR="$commands[$editor]"
                        break
                fi
        done
-       unset editor
+       unset editor x11_editors
 fi
 
 case "$EDITOR:t" in
-       "atom"|"mate"|"subl")
+       "code"|"atom"|"mate"|"subl")
                EDITOR="$EDITOR --wait"
                ;;
+       "mvim"|"gvim")
+               EDITOR="$EDITOR --nofork"
+               ;;
 esac
 
-if [ -n "$EDITOR" ]; then
+if [[ -n "$EDITOR" ]]; then
        export EDITOR
        alias zshenv="$EDITOR ~/.zshenv"
 fi