1

Autojump or z let you move around in your filesystem by entering only a part of the entire path (e.g. z foo takes me to /long/long/path/to/foo).

I often want to jump to a path, do something, and get back. This is easily achieved by using cd -.

However, if I jump to the path, cd around a little, then want to "get back", cd - would no longer work.

It would also not work if I started in dir a, wanted to jump to b, then to c, then "back" (to b) and "back" (to a).

Having to remember the name of where I want to jump back to (so I can do z a instead of "jump back") is no fun.

pushd and popd are built exactly to help you navigate through a stack of directories. I was wondering, if I could integrate the partial matching behavior of z with pushd and popd?

There seems to be no command line option in z or autojump which would give the target directory instead of cd'ing to it, otherwise I'd try pushd $(z ...).

1 Answer 1

0

Not sure how I missed this, but z has a -e option that echoes the best match instead of cding to it.

I'll give an example of how to use this in fish shell

> pushd (z -e ...)

You can also use fish abbreviations to abbreviate ze to z -e. I am not sure if there is a way to set an abbreviation to automatically expand to pushd (z -e ...) with your cursor behind the closing bracket.

1
  • I'll leave the answer un-accpeted as it does not include information for autojump and there might be more convenient ways to achieve this Commented Mar 12, 2020 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .