I never use my bin or pkg golang dirs. So when I do this:
cd go
i'd rather BASH assume I mean
cd go/src
how can I tell bash do this everytime?
Put
function cd()
{
test $# -eq 0 && return 0
if [ `basename $1` == "go" ]; then
builtin cd "$1/src"
else
builtin cd "$@"
fi
}
in your ~/.bashrc
.
Note that you won't be able to use command-line options when cd
-ing into your Go directory because ideally we'd process only the last argument passed to cd
but you can't easily do this in a POSIX shell (and bash
).