From f892f5d60520602ed81de24022885f09e70215e7 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Tue, 25 Oct 2022 03:11:53 -0500 Subject: [PATCH] Move PATH API to its own module --- .bashrc | 20 -------------------- dotlib/generic-pre/path.sh | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 20 deletions(-) create mode 100644 dotlib/generic-pre/path.sh diff --git a/.bashrc b/.bashrc index fa1bd14..26dac22 100644 --- a/.bashrc +++ b/.bashrc @@ -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 ### diff --git a/dotlib/generic-pre/path.sh b/dotlib/generic-pre/path.sh new file mode 100644 index 0000000..12980d3 --- /dev/null +++ b/dotlib/generic-pre/path.sh @@ -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%:} +}