Move PATH API to its own module

This commit is contained in:
Nick Chambers 2022-10-25 03:11:53 -05:00
parent 907ee8e6c9
commit f892f5d605
2 changed files with 15 additions and 20 deletions

20
.bashrc
View File

@ -42,26 +42,6 @@ __dotlib_set_SHOPTS
ulimit -c unlimited
###
# Search Path Manager
###
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%:}
}
###
# Library loader
###

View File

@ -0,0 +1,15 @@
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%:}
}