rupa / z

z - jump around
Do What The F*ck You Want To Public License
16.17k stars 1.16k forks source link

z history is pruned if a filesystem is not mounted #307

Open systemmonkey42 opened 2 years ago

systemmonkey42 commented 2 years ago

Issue: If I use z when a filesystem (like /home) is unmounted, all references to /home are instantly purged from the cd history.

This has caught me out enough times ( I have a 100TB zfs pool I unmount for maintenance occasionally ) that I use a patched z which tracks the mountpoint.

Missing paths are filtered as normal when deciding where to go, but paths are only deleted if they are missing AND the mountpoint is actually mounted.

rupa commented 2 years ago

not opposed to a way to deal with this, but not 100 sure how I'd go about it. If you want to share your patch maybe I'll get inspired :) (or a PR if your implementation is tidy)

systemmonkey42 commented 2 years ago

Hi

Unfortunately my code isn't a "patch" to your code, but more of a reimplementation "inspired" by z which suits my needs.

The mountpoint stuff is also linux specific in that it reads /proc/self/mounts rather than parsing the output of df, but I'm pretty sure they are very similar (make sure you use the -P flag on df if it is supported on the platform you are using.)

The logic was simple:

Regards

agkozak commented 2 years ago

My ZSH-z plugin accomplishes this by having a ZSHZ_KEEP_DIRS array of directories that should never be removed and whose subdirectories should never be removed. Something similar could be done in the _z_dirs function.