dotfiles/dotlib/pre/path.sh

15 lines
319 B
Bash

add-path() {
local path paths path_list=( )
declare -A uniq_paths
IFS=: read -ra paths <<< "$PATH"
for path in "$@" "${paths[@]}"; do
if [[ ! -v uniq_paths[$path] ]]; then
uniq_paths[$path]=42
path_list+=("$path")
fi
done
printf -v path %s: "${path_list[@]}"
export PATH=${path%:}
}