Skip to content

Instantly share code, notes, and snippets.

@olebedev
Last active September 5, 2016 14:41
Show Gist options
  • Save olebedev/8328941 to your computer and use it in GitHub Desktop.
Save olebedev/8328941 to your computer and use it in GitHub Desktop.
MAIN_GOPATH=/usr/local/Cellar/go/1.2/workspace
export GOPATH=$MAIN_GOPATH
MAIN_PATH=$PATH:$GOPATH/bin
export PATH=$MAIN_PATH
# goenv functions
activate(){
export GOPATH="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)"
export OLDPS1=$PS1
export PS1="(go:$(basename $GOPATH)) $PS1"
mkdir -p $GOPATH/bin
mkdir -p $GOPATH/pkg
mkdir -p $GOPATH/src/$(basename $GOPATH)
export PATH=$GOPATH/bin:$PATH
alias gcd="cd $GOPATH/src/$(basename $GOPATH)"
deactivate() {
echo "Goodbye! =)"
cd $GOPATH
echo "Now, you in \`$(pwd)\` directory."
export PS1=$OLDPS1
export GOPATH=$MAIN_GOPATH
export PATH=$MAIN_PATH
unset OLDPS1
unalias gcd
unset deactivate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment