dotfiles/dotfiles/lib/shellenv.sh

85 lines
2.9 KiB
Bash
Raw Normal View History

2014-11-21 00:01:50 -07:00
source ~/.lib/shellenv/functions.sh
command -v greadlink > /dev/null && alias readlink="greadlink"
2014-11-21 00:01:50 -07:00
function _source_shellenv_files {
for filename in ~/.lib/shellenv/*; do
source $filename
done
}
2016-01-05 20:50:42 -07:00
function add_to_path {
local result=$($HOME/.lib/python/shell_path.py --include-assignment "$@")
eval "$result"
}
function _setup_env {
_path_helper
2016-01-05 20:50:42 -07:00
add_to_path "$HOME/.local/lib/python2.6/site-packages" --after
add_to_path "$HOME/.rvm/bin" --after
add_to_path "$HOME/bin"
hash brew 2>/dev/null && add_to_path "$(brew --prefix coreutils)/libexec/gnubin"
add_to_path "/usr/local/bin"
2016-01-05 20:50:42 -07:00
add_to_path $(python -c 'import sysconfig; print sysconfig.get_path("scripts")') --before
2015-12-13 18:20:46 -07:00
if is_osx; then
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
2016-01-05 20:50:42 -07:00
add_to_path "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources" --after
local JDK_LOCATION="$(find /Library/Java/JavaVirtualMachines -depth 1 | head -n 1)"
export JAVA_HOME="$JDK_LOCATION/Contents/Home"
export STUDIO_JDK=$JDK_LOCATION
export GRADLE_HOME="$(brew --prefix gradle)"
export ANDROID_HOME="$(brew --prefix android-sdk)"
2016-01-05 20:50:42 -07:00
add_to_path "$ANDROID_HOME" --after
# Access gnu man pages.
hash brew 2> /dev/null && export MANPATH="$(brew --prefix)/opt/coreutils/libexec/gnuman:$MANPATH"
else
export JAVA_HOME="$(update-alternatives --config java | get_cols ' -1' | head -n 1)"
is_osx && export VISUAL="which emacsclient -c -n"
fi
2016-01-05 20:50:42 -07:00
add_to_path "$JAVA_HOME/bin"
2016-01-05 20:50:42 -07:00
add_to_path "$HOME/.lib/python" --after
add_to_path "/usr/local/sbin" --after
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
function with_shellrc {
zsh -c "source ~/.zshrc && ""$@"
}
# Travis completion
[ -f "$HOME/.travis/travis.sh" ] && source "$HOME/.travis/travis.sh"
2015-04-28 14:44:03 -06:00
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/"
2015-06-29 16:11:12 -06:00
2016-01-05 20:50:42 -07:00
add_to_path "$HOME/.local/bin"
add_to_path "$HOME/.lib/python" --path-var 'PYTHONPATH'
2016-01-05 20:50:42 -07:00
add_to_path "$HOME/go" --path-var 'GOPATH'
add_to_path "${GOPATH//://bin:}/bin"
2015-09-04 01:04:28 -06:00
export RBENV_ROOT=/usr/local/var/rbenv
2016-01-05 20:50:42 -07:00
add_to_path "$HOME/.rbenv/bin"
hash rbenv 2> /dev/null && eval "$(rbenv init -)"
2016-01-05 20:50:42 -07:00
hash brew 2>/dev/null && add_to_path "$(brew --prefix coreutils)/libexec/gnubin"
2016-01-05 20:50:42 -07:00
add_to_path "$HOME/.lib/bin"
export ENVIRONMENT_SETUP_DONE="$(date)"
}
function _path_helper {
export PATH_HELPER_RAN="$(date)"
eval `/usr/libexec/path_helper -s`
}
environment_variable_exists PATH_HELPER_RAN || _path_helper
environment_variable_exists ENVIRONMENT_SETUP_DONE || _setup_env
_source_shellenv_files