dotfiles/.config/zsh/conf.d/10-path.zsh

19 lines
501 B
Bash
Raw Normal View History

2020-05-24 23:16:31 +02:00
# Set $PATH
# Put only directories in $PATH that exist and remove duplicates
2024-10-28 22:28:56 +01:00
typeset -U path # No duplicates
2020-05-24 23:16:31 +02:00
path=()
_prepath() {
2024-10-28 22:28:56 +01:00
for dir in "$@"; do
dir=${dir:A}
[[ ! -d "$dir" ]] && return
path=("$dir" $path)
done
2020-05-24 23:16:31 +02:00
}
2021-01-13 23:29:53 +01:00
_prepath /usr/bin /bin /usr/sbin /sbin /usr/local/bin /usr/local/sbin # BSD and macOS
2024-10-28 22:28:56 +01:00
_prepath /opt/homebrew/bin /opt/homebrew/sbin /usr/local/bin # Homebrew on macOS
_prepath ~/bin ~/.local/bin # $HOME
2020-05-24 23:16:31 +02:00
unfunction _prepath