Skip to content

Instantly share code, notes, and snippets.

@endophage
Created December 18, 2015 19:06
Show Gist options
  • Save endophage/2b0ccc69ab7b0bed220c to your computer and use it in GitHub Desktop.
Save endophage/2b0ccc69ab7b0bed220c to your computer and use it in GitHub Desktop.
gocd bash
# Bash wrapper to change directory to the output of gocd
gocd () {
if [ -d "$GOPATH/src/$1" ]; then
cd "$GOPATH/src/$1"
fi
}
# Optional tab completion wrapper for $GOPATH/src
_gopath () {
local cur
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
k=0
for j in $( compgen -f "$GOPATH/src/$cur" ); do
if [ -d "$j" ]; then
COMPREPLY[k++]=${j#$GOPATH/src/}
fi
done
}
complete -o nospace -F _gopath gocd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment