Refactor zsh_env startup so that it is possible to override PATH
variable once it has already been configured.
This commit is contained in:
@@ -33,6 +33,32 @@ function add_to_back_of_path {
|
||||
export $target="$(_add_to_back_of_path_lines $1 $target | tr '\n' ':' | remove_trailing_colon)"
|
||||
}
|
||||
|
||||
function idem_add_to_front_of_path {
|
||||
target=${2-PATH}
|
||||
exists_in_path_var $1 $target || add_to_front_of_path $1 $target
|
||||
}
|
||||
|
||||
function idem_add_to_back_of_path {
|
||||
target=${2-PATH}
|
||||
exists_in_path_var $1 $target || add_to_back_of_path $1 $target
|
||||
}
|
||||
|
||||
function indirect_expand {
|
||||
eval "value=\"\${$1}\""
|
||||
echo $value
|
||||
}
|
||||
|
||||
function environment_variable_exists {
|
||||
eval "value=\"\${$1+x}\""
|
||||
[ ! -z $value ]
|
||||
}
|
||||
|
||||
function exists_in_path_var {
|
||||
target=${2-PATH}
|
||||
local path_contents="$(indirect_expand $target)"
|
||||
[[ ":$path_contents:" == *":$1:"* ]]
|
||||
}
|
||||
|
||||
function split_into_vars () {
|
||||
local string IFS
|
||||
|
||||
@@ -347,6 +373,7 @@ function parse_timestamp {
|
||||
}
|
||||
|
||||
function refresh_config {
|
||||
unset ENVIRONMENT_SETUP_DONE
|
||||
source ~/.zshenv
|
||||
source ~/.zshrc
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ export UBER_OWNER="imalison@uber.com"
|
||||
[ -z "$GIT_SSH" ] || export GIT_SSH="$HOME/.lib/git-ssh.sh"
|
||||
export VAGRANT_DEFAULT_PROVIDER=aws
|
||||
[ -s "/usr/local/bin/virtualenvwrapper.sh" ] && . /usr/local/bin/virtualenvwrapper.sh
|
||||
[ -s "$HOME/.nvm/nvm.sh" ] && . $HOME/.nvm/nvm.sh
|
||||
|
||||
cdsync () {
|
||||
cd $(boxer sync_dir $@)
|
||||
|
Reference in New Issue
Block a user