Created
December 18, 2015 19:06
-
-
Save endophage/2b0ccc69ab7b0bed220c to your computer and use it in GitHub Desktop.
gocd bash
This file contains 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
# 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