[zsh] Replace implementation of init_path with update-path call

Rename this function with hyphens instead of underscores.
This commit is contained in:
Eryn Wells 2024-09-23 14:44:26 -07:00
parent 02f5655426
commit 2d43ef9a1e
3 changed files with 27 additions and 48 deletions

26
zsh/func/init-path Normal file
View file

@ -0,0 +1,26 @@
# Eryn Wells <eryn@erynwells.me>
autoload -Uz update-path
function init-path
{
update-path \
"$HOME/bin" \
"$HOME/.local/bin" \
"$HOME/.cargo/bin" \
"$HOME/.ghcup/bin" \
"$HOME/.gem/ruby/2.2.0/bin" \
"$HOME/.vim/bundle/vim-tidal/bin" \
/opt/local/bin \
/usr/X11/bin \
/opt/brew/bin \
/opt/homebrew/bin \
/usr/local/bin \
/usr/bin \
/bin \
/usr/local/sbin \
/usr/sbin \
/sbin
}
init-path "$@"

View file

@ -1,47 +0,0 @@
# Eryn Wells <eryn@erynwells.me>
autoload -Uz append_to_path
init_path() {
local should_be_verbose=0
while getopts "v" opt; do
case $opt in
"v") should_be_verbose=1;;
"+v") should_be_verbose=0;;
*) ;;
esac
done
local verbose_flag=''
if (( $should_be_verbose )); then
verbose_flag='-v'
fi
for p in \
"$HOME/bin" \
"$HOME/.local/bin" \
"$HOME/.cargo/bin" \
"$HOME/.ghcup/bin" \
"$HOME/.gem/ruby/2.2.0/bin" \
"$HOME/.vim/bundle/vim-tidal/bin" \
"/opt/local/bin" \
"/usr/X11/bin" \
"/opt/brew/bin" \
"/opt/homebrew/bin" \
"/usr/local/bin" \
"/usr/bin" \
"/bin" \
"/usr/local/sbin" \
"/usr/sbin" \
"/sbin"
do
append_to_path +e $verbose_flag "$p"
done
export path
rehash
}
init_path "$@"