dotfiles.2022/_home/dot_sz.shrc.d/10_path.env

29 lines
761 B
Bash
Raw Normal View History

append_to_envvar() {
local __VAL_tmp_=$(eval "echo '$1'")
local __VAL_tmp_=$(echo "$__VAL_tmp_" | sed "s/${2}//" )
$1=$__VAL_tmp_${2}
}
insert_to_envvar() {
local __VAL_tmp_=$(eval "echo '$1'")
local __VAL_tmp_=$(echo "$__VAL_tmp_" | sed "s/${2}//" )
$1=${2}$__VAL_tmp_
}
2022-08-26 18:30:33 +00:00
get_clean_path() {
sed 's/ *:\?$//g;s/`/``/g;s/:/`:`/g;s/\\`:`/\\:/g;' <<< $1 | \
awk -v RS='`:`' -v ORS='`:`' '!arr[$0]++' | \
sed 's/`:`/:/g;s/:$//g'
}
# set PATH so it includes user's private bin if it exists
if [[ -d "$HOME/bin" ]] ; then
export PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [[ -d "$HOME/.local/bin" ]] ; then
export PATH="$HOME/.local/bin:$PATH"
fi
PATH=$( get_clean_path $PATH )