From: Alexander Barton Date: Mon, 8 Jun 2015 13:08:28 +0000 (+0200) Subject: "editor_select": Simplify script X-Git-Url: https://arthur.barton.de/gitweb/?p=OhMyZshExtensions.git;a=commitdiff_plain;h=338fb793cd6fa37b06e5646885c9b88b556279fc "editor_select": Simplify script --- diff --git a/plugins/editor_select/editor_select.plugin.zsh b/plugins/editor_select/editor_select.plugin.zsh index cd75883..afa1bf0 100644 --- a/plugins/editor_select/editor_select.plugin.zsh +++ b/plugins/editor_select/editor_select.plugin.zsh @@ -1,31 +1,19 @@ # editor-select.plugin.zsh -if [ -z "$EDITOR" ]; then - # Check "atom" - EDITOR=$(which atom 2>/dev/null) - if [ $? -eq 0 ]; then - EDITOR="$EDITOR --wait" - else - # 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 +for editor in atom mate subl vim vi; do + if [ -n "$commands[$editor]" ]; then + EDITOR="$commands[$editor]" + break fi -fi +done +unset editor + +case "$(basename "$EDITOR")" in + "atom"|"mate"|"subl") + EDITOR="$EDITOR --wait" + ;; +esac + if [ -n "$EDITOR" ]; then export EDITOR alias zshrc="$EDITOR ~/.zshrc"