From ae6fd37cf9044fc1c52fd97d506ac12027a4118d Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Mon, 23 Sep 2024 18:21:34 -0700 Subject: [PATCH] [zsh] Move init_env_vi -> init-vi and make it a proper function --- zsh/func/init-vi | 18 ++++++++++++++++++ zsh/func/init_env_vi | 14 -------------- zshenv | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 zsh/func/init-vi delete mode 100644 zsh/func/init_env_vi diff --git a/zsh/func/init-vi b/zsh/func/init-vi new file mode 100644 index 0000000..f0e1dc7 --- /dev/null +++ b/zsh/func/init-vi @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh +# Eryn Wells + +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 "$@" diff --git a/zsh/func/init_env_vi b/zsh/func/init_env_vi deleted file mode 100644 index 879b14c..0000000 --- a/zsh/func/init_env_vi +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env zsh -# Eryn Wells - -# 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 diff --git a/zshenv b/zshenv index 14201aa..22b34ac 100644 --- a/zshenv +++ b/zshenv @@ -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 \ )