feat: Split _path_add into _path_append and _path_prepend
_path_add only ever appended to PATH, which didn't fit profile.d/krew and profile.d/anyenv (they prepend, to take priority). Rename it to _path_append for clarity and add _path_prepend alongside it, so both orderings get the same dedup guard when needed — krew and anyenv aren't converted yet, kept as plain PATH concatenation until then.
This commit is contained in:
+7
-1
@@ -25,12 +25,18 @@ function _source_dir_files() {
|
||||
}
|
||||
|
||||
# Source : https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
|
||||
_path_add() {
|
||||
_path_append() {
|
||||
if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
|
||||
PATH="${PATH:+"${PATH}:"}$1"
|
||||
fi
|
||||
}
|
||||
|
||||
_path_prepend() {
|
||||
if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
|
||||
PATH="$1${PATH:+":${PATH}"}"
|
||||
fi
|
||||
}
|
||||
|
||||
_prompt_command_add() {
|
||||
if [ -n "$1" ] && [[ ":${PROMPT_COMMAND}:" != *":$1:"* ]]; then
|
||||
PROMPT_COMMAND="${PROMPT_COMMAND:+"${PROMPT_COMMAND};"}$1"
|
||||
|
||||
Reference in New Issue
Block a user