zsh-z: Don't z into subdirectories

Assume I have a directory structure like:

/foo
/foo/bar
/foo/baz
/foobar

/foo is my main folder from which I cd into bar and baz on a regular basis. When I run z foo, it will now jump me to /foo/bar since it is the folder I currently use the most. But I find this counter-intuitive and would prefer to land in /foo.

A solution to this is to only match the actual directory’s name, ignoring all of the parent directories.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 35 (21 by maintainers)

Most upvoted comments

@piegamesde @peterjuras I’m happy enough with how the new, alternate behavior works that I’ve merged it onto the master branch, so you may go back to using that, but be sure to set ZSHZ_UNCOMMON=1 in your .zshrc to make it kick in.

Thanks very much, both of you, for helping to improve ZSH-z.

I’m still working on this – I haven’t forgotten. Be well.

Yes, I see what you mean. I’ll work on this for a few days and see what I can come up with.

then z foo has a match that isn’t in common with all the others. Should it go to /foo or /home/me/foo?

Honestly, I don’t really care if /foo is chosen over /home/me/foo or not. My problem is that – following your example – I type z foo and end up in /home/me/foo/a (because I use that folder really often).