Created
June 25, 2013 14:30
-
-
Save rahulg/5858911 to your computer and use it in GitHub Desktop.
Virtualenv-like activate & deactivate for golang. Source this file the normal way from bash to activate the GOPATH, deactivate to deactivate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export GOPATH="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)" | |
export OLDPS1=$PS1 | |
export PS1="[go:$(basename $GOPATH)] $PS1" | |
alias gcd="cd $GOPATH" | |
deactivate() { | |
export PS1=$OLDPS1 | |
unset GOPATH | |
unset OLDPS1 | |
unalias gcd | |
unset deactivate | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I forked this to add
builtin
to thecd
. This prevents issues whencd
is aliased to something else - for instance,cd() { builtin cd $1 && ls }
.