forked from colonelpanic/dotfiles
Path functions refactor/ add ~/.lib/python to PYTHONPATH
This commit is contained in:
@@ -1,3 +1,38 @@
|
||||
function path_lines {
|
||||
target=${1-PATH}
|
||||
if is_zsh; then
|
||||
echo ${(P)target} | tr ':' '\n'
|
||||
else
|
||||
echo ${!target} | tr ':' '\n'
|
||||
fi
|
||||
}
|
||||
|
||||
function _add_to_front_of_path_lines {
|
||||
target=${2-PATH}
|
||||
echo $1
|
||||
path_lines $target | grep -Ev "^$1$"
|
||||
}
|
||||
|
||||
function _add_to_back_of_path_lines {
|
||||
target=${2-PATH}
|
||||
path_lines $target | grep -Ev "^$1$"
|
||||
echo $1
|
||||
}
|
||||
|
||||
function remove_trailing_colon {
|
||||
sed 's|:*$||'
|
||||
}
|
||||
|
||||
function add_to_front_of_path {
|
||||
target=${2-PATH}
|
||||
export $target="$(_add_to_front_of_path_lines $1 $target | tr '\n' ':' | remove_trailing_colon)"
|
||||
}
|
||||
|
||||
function add_to_back_of_path {
|
||||
target=${2-PATH}
|
||||
export $target="$(_add_to_back_of_path_lines $1 $target | tr '\n' ':' | remove_trailing_colon)"
|
||||
}
|
||||
|
||||
function split_into_vars () {
|
||||
local string IFS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user