[zsh] Move init_env_vi -> init-vi and make it a proper function

This commit is contained in:
Eryn Wells 2024-09-23 18:21:34 -07:00
parent 9ef882cb84
commit ae6fd37cf9
3 changed files with 19 additions and 15 deletions

18
zsh/func/init-vi Normal file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env zsh
# Eryn Wells <eryn@erynwells.me>
function init-vi
{
# Prefer nvim and vim, in that order, over standard vi, which is insufferable.
if whence -cp nvim &> /dev/null; then
alias vi=nvim
export EDITOR=nvim
elif whence -cp vim &> /dev/null; then
alias vi=vim
export EDITOR=vim
else
export EDITOR=vi
fi
}
init-vi "$@"

View file

@ -1,14 +0,0 @@
#!/usr/bin/env zsh
# Eryn Wells <eryn@erynwells.me>
# Prefer nvim and vim, in that order, over standard vi, which is insufferable.
if whence -cp nvim &> /dev/null; then
alias vi=nvim
export EDITOR=nvim
elif whence -cp vim &> /dev/null; then
alias vi=vim
export EDITOR=vim
fi
export editor=vi

2
zshenv
View file

@ -26,7 +26,7 @@ typeset -a zsh_init_env_functions=( \
init-zsh-helpers \
init_env_python \
init_env_playdate \
init_env_vi \
init-vi \
init_env_$SYS \
)