Last active
February 23, 2016 02:41
-
-
Save songgao/572a51f5883422a52f39 to your computer and use it in GitHub Desktop.
Shell functions for quickly `cd` into Go packages' source directories
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
gprefresh() { | |
go list -f "{{.Dir}}" ... 2>/dev/null > $GOPATH/.list; | |
} | |
_gpcd() { | |
if [ "$#" -eq 1 ]; then | |
cd $1 | |
else | |
select p in $@; do | |
_gpcd $p | |
unset p | |
break | |
done | |
fi | |
} | |
gpcd() { | |
_gpcd $(echo $(grep --color=never '/'$1'$' "$GOPATH/.list")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment