edit
is not at all portable here:
|
alias aliases='edit ${ZSH:-${HOME}/.oh-my-${SHELL##*/}}/custom/aliases.${SHELL##*/}; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login' |
|
alias ohmyzsh='cd ${ZSH:-${HOME}/.oh-my-${SHELL##*/}}' |
|
alias zshconfig='edit ${HOME}/.${SHELL##*/}rc; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login' |
|
alias zshenv='edit ${HOME}/.${SHELL##*/}env; . ${HOME}/.${SHELL##*/}rc && exec ${SHELL##*/} --login' |
A solution like ${EDITOR:-vi}
¹ instead of edit
² is portable and should replace it.
- this may not be the correct if-not-𝑥-then-𝑦 syntax when calling a binary like
/usr/bin/vi
, but it’s close
edit
is defined as:
|
if command -v nvim > /dev/null 2>&1; then |
|
EDITOR="nvim" |
|
elif command -v vim > /dev/null 2>&1; then |
|
EDITOR="vim" |
|
elif command -v vi > /dev/null 2>&1; then |
|
EDITOR="vi" |
|
else |
|
EDITOR="nano" |
|
fi |
|
export EDITOR |
|
# https://github.com/koalaman/shellcheck/wiki/SC2139/db553bf16fcb86b2cdc77b835e75b9121eacc429#this-expands-when-defined-not-when-used-consider-escaping |
|
alias editor='$EDITOR' |
|
alias edit="editor" |