From b909e4f691d23d5c65bb5d7107390fe393a95c11 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Fri, 15 Jul 2016 10:19:31 -0700 Subject: [bash] don't build the PATH blindly Check if directories / files exist before adding them to the path or sourcing them. --- bashrc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'bashrc') diff --git a/bashrc b/bashrc index c80a18d..b48f69b 100644 --- a/bashrc +++ b/bashrc @@ -7,10 +7,10 @@ export PAGER="less" export TZ=America/Los_Angeles export GOPATH="${HOME}/gocode" -export PATH="${GOPATH}/bin:${HOME}/bin:/opt/twitter/opt/go/libexec/bin:${PATH}" - [ -z "$PS1" ] && return +[ "${BASH_VERSINFO}" -gt 3 ] && shopt -s autocd + # prompts export PS1="\W % " @@ -25,18 +25,27 @@ alias lt="ls -lhtr" alias mv="mv -i" alias rm="rm -i" -alias utc="date -u" -alias k="kubectl" -alias camera-backup="pbackup --bucket fcuny-photos --project fcuny-backups --import-path /Volumes/a6000/DCIM/100MSDCF/" - +alias au="aurora" alias g="git" -alias gclean="git clean -dfx" +alias k="kubectl" +alias camera-backup="pbackup --bucket fcuny-photos --project fcuny-backups --import-path /Volumes/a6000/DCIM/100MSDCF/" alias docker-restart="docker-machine restart default" - alias get-transactions="transactions --dataset fcuny_finance_transactions --project fcuny-devel" +alias gobknest="ssh -K bookkeeper@nest.smfc.twitter.com" +alias goebnest="ssh -K eventbus@nest.smfc.twitter.com" +alias gonest="ssh -K nest.smfc.twitter.com" + +# finally, build the path +[ -d "${HOME}/bin" ] && PATH="${HOME}/bin:${PATH}" +[ -d "${GOPATH}/bin" ] && PATH="${GOPATH}/bin:${PATH}" +[ -d "${HOME}/src/source/dist" ] && PATH="${HOME}/src/source/dist:${PATH}" [ -f "${HOME}/google-cloud-sdk/path.bash.inc" ] && source "${HOME}/google-cloud-sdk/path.bash.inc" [ -f "${HOME}/google-cloud-sdk/completion.bash.inc" ] && source "${HOME}/google-cloud-sdk/completion.bash.inc" -[ -f "${HOME}/.bash_local" ] && source "${HOME}/.bash_local" +[ -d "/opt/twitter/opt/go/libexec/bin" ] && PATH="/opt/twitter/opt/go/libexec/bin:${PATH}" +[ -d "/opt/twitter/bin" ] && PATH="/opt/twitter/bin:${PATH}" +[ -f /opt/twitter/rvm/scripts/rvm ] && source /opt/twitter/rvm/scripts/rvm + + -- cgit 1.4.1