Skip to content

Instantly share code, notes, and snippets.

@saml
Created October 7, 2015 14:56
Show Gist options
  • Save saml/90ed8b4a61aae3168353 to your computer and use it in GitHub Desktop.
Save saml/90ed8b4a61aae3168353 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [[ -z ${ORIGINALGOPATH+x} ]]
then
ORIGINALGOPATH="$GOPATH"
ORIGINALPS1="$PS1"
GOPATH="${PWD}/vendor:${PWD}:$ORIGINALGOPATH"
PROJDIR="${PWD##*/}"
PS1="${ORIGINALPS1}GO($PROJDIR)> "
echo "Activating..."
echo "GOPATH = $GOPATH"
deactivate() {
export GOPATH="$ORIGINALGOPATH"
export PS1="$ORIGINALPS1"
echo "Deactivating..."
echo "GOPATH = $GOPATH"
unset -v ORIGINALGOPATH
unset -v ORIGINALPS1
unset -f deactivate
}
else
echo "Already activated. You may deactivate"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment