This may be better handled with cdpath, which is available in both Zsh and Bash.
If arg does not begin with a slash, the behaviour depends on whether the current directory ā.ā occurs in the list of directories contained in the shell parameter cdpath. If it does not, first attempt to change to the directory arg under the current directory, and if that fails but cdpath is set and contains at least one element attempt to change to the directory arg under each component of cdpath in turn until successful.
Combined with auto_cd in Zsh, you get the same effect as defining all these aliases.
Alternatively, use a tool like ghq to handle organization for you. GHQ clones repos in much the same way that go get does; in fact, you could set $GHQ_ROOT to $GOPATH/src to unify git repos and go packages.
I use fzf and a shell alias to filter and select existing repositories from a menu.
cdg () {
if [ -z "$1" ]
then
cdto=$(ghq list | fzf)
else
cdto=$(ghq list | fzf -q "$@")
fi
[ "$cdto" = '' ] || cd "$GHQ_ROOT/$cdto" || return 1
}
This may be better handled with
cdpath
, which is available in both Zsh and Bash.Combined with
auto_cd
in Zsh, you get the same effect as defining all these aliases.cdpath
looked extremely attractive to me but it appears that you need to install extra completion functions to make it work with tab completion. Drat.That looks like a great solution. Iām going to give this a try. Thanks for info.
I used CDPATH for a while. Turned it off because it was too confusing for me.
It even broke a build once because some shell script deep down changed its behavior due to CDPATH. It took quite a while to debug.
I aliased
j
to something similar in my zshrc.That lets me say:
To jump to
project-1
ās directory.Explicit, terse, supports completion, and only a few lines of zsh.
Or use z
Alternatively, use a tool like ghq to handle organization for you. GHQ clones repos in much the same way that
go get
does; in fact, you could set$GHQ_ROOT
to$GOPATH/src
to unify git repos and go packages.I use fzf and a shell alias to filter and select existing repositories from a menu.
Screenshot: https://i.imgur.com/hitb195.png
I use autojump for this. It works out of the box on both Bash and Zsh without any changes to your shell configuration!
Here is my way with autocomplete