From 491c1b1faa553901f58df5bf789bffc78382e8f7 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Fri, 13 Nov 2020 12:04:43 +0100 Subject: [PATCH] config/shell: fix default editor --- .config/shell/functions | 2 +- .config/zsh/.zshrc | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.config/shell/functions b/.config/shell/functions index cf1c4ba..f1fe151 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -20,7 +20,7 @@ alias editenv='sudoedit /etc/environment' editright() { test ! -f "$1" && mkdir -p $(dirname "$1") || sudo mkdir -p $(dirname "$1") echo "Editing $1..." - test -O "$1" && $EDITOR "$1" || sudoedit "$1" + (test -O "$1" || (test ! -f "$1" && test -O $(dirname "$1"))) && $EDITOR "$1" || sudoedit "$1" } # Underline arg diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 818858e..2e84ab7 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -164,11 +164,7 @@ alias zln='noglob zmv -L' alias zsy='noglob zmv -Ls' # Preferred editor for local and remote sessions -if [[ -n $SSH_CONNECTION ]]; then - export EDITOR='vim' -else - export EDITOR='nvim' -fi +which nvim >/dev/null && export EDITOR='nvim' || export EDITOR='vim' for file in $CONFIG_SHELLS/*; do source $file; done