From: Alexander Barton Date: Sat, 18 Jul 2015 01:43:18 +0000 (+0200) Subject: Add "editor_select" plugin to auto-configure $EDITOR variable X-Git-Url: https://arthur.barton.de/gitweb/?p=ax-zsh.git;a=commitdiff_plain;h=13fdff629c7064ac3312abd93201064e0ffa6e4b Add "editor_select" plugin to auto-configure $EDITOR variable --- diff --git a/plugins/editor_select/editor_select.zprofile b/plugins/editor_select/editor_select.zprofile new file mode 100644 index 0000000..08a0cf0 --- /dev/null +++ b/plugins/editor_select/editor_select.zprofile @@ -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