From ba293f30ab2b7af6ed17aebf9ed84fb159ddd852 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Mon, 13 May 2019 00:15:45 +0200 Subject: [PATCH] editor_select: Add support for "code", "mvim", "gvim" --- plugins/editor_select/editor_select.zprofile | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/editor_select/editor_select.zprofile b/plugins/editor_select/editor_select.zprofile index a5c3173..982d9b8 100644 --- a/plugins/editor_select/editor_select.zprofile +++ b/plugins/editor_select/editor_select.zprofile @@ -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 -- 2.39.2