1. 10
    1. 10

      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.

      1. 5

        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.

      2. 2

        That looks like a great solution. Iā€™m going to give this a try. Thanks for info.

      3. 2

        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.

    2. 3

      I aliased j to something similar in my zshrc.

      That lets me say:

       $ j project-1

      To jump to project-1ā€™s directory.

      Explicit, terse, supports completion, and only a few lines of zsh.

    3. 2

      Or use z

    4. 2

      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" ]
      		cdto=$(ghq list | fzf) 
      		cdto=$(ghq list | fzf -q "$@") 
      	[ "$cdto" = '' ] || cd "$GHQ_ROOT/$cdto" || return 1

      Screenshot: https://i.imgur.com/hitb195.png

    5. 1

      I use autojump for this. It works out of the box on both Bash and Zsh without any changes to your shell configuration!