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