forked from colonelpanic/dotfiles
Path functions refactor/ add ~/.lib/python to PYTHONPATH
This commit is contained in:
parent
443f8607df
commit
f94232acf0
@ -1,15 +1,5 @@
|
||||
source ~/.lib/shellenv/functions.sh
|
||||
|
||||
function add_to_front_of_path {
|
||||
export PATH=$@:$(echo $PATH | sed "s|:*$@||g" | sed "s|^:||")
|
||||
}
|
||||
|
||||
function add_to_back_of_path {
|
||||
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
|
||||
PATH="${PATH:+"$PATH:"}$1"
|
||||
fi
|
||||
}
|
||||
|
||||
add_to_back_of_path "$HOME/.local/lib/python2.6/site-packages"
|
||||
add_to_back_of_path "$HOME/.rvm/bin"
|
||||
add_to_front_of_path "$HOME/bin"
|
||||
@ -64,3 +54,5 @@ test -e /usr/libexec/path_helper && eval `/usr/libexec/path_helper -s`
|
||||
export NVM_DIR="/Users/imalison/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
export NODE_PATH="/usr/local/lib/node_modules/"
|
||||
|
||||
add_to_front_of_path "~/.lib/python" 'PYTHONPATH'
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user