knu-z v2.0 released – a fork of “z”, a better “cd”

I am happy to announce that my fork of “z”, which was originally developed by rupa deadwyler, has reached the functionality level I aimed, and here I present you the very first release, knu-z v2.0, available for both zsh and bash. (The original is now at v1.5, hence v2.0)

Here is a list of user-side improvements I’ve made over the original version:

  • Search method enhancements
    • Adopted simple substring match instead of regular expression match, for those who often go under directories with dots in the name.
    • While it’s basically substring match, there is special syntax for searching by prefix and/or suffix.
    • $HOME part is ignored in matching.  Otherwise, it often gets in your way if you like to take your project names from your handle, or just by annoying coincidence.
  • Shell completion enhancements
    • Rewrote bash completion that didn’t seem working.
    • Rewrote zsh completion that was old (compctl) with the new completion system (“compsys”) for far better UI.
    • Subdirectories of your home directory show up like ~/src/project1 instead of /home/user/src/project1. [bash] [zsh]
    • Completion candidates are sorted by the score. [zsh]
    • Glob patterns can be used to narrow down candidates. [bash] [zsh]
    • Enhances cd by powering its completion function to include matching directories in the z database.  This almost eliminates the need for learning and “using” z.  Once you install “z”, the normal cd simply gets smart, and it automatically learns as you use it normally.
  • Other enhancements
    • Added a way to manually remove a directory from the database: z --del directory
    • Nonexistent directories are not immediately eliminated from the database.  It is worth keeping a directory on a certain removable medium or a remote disk that you often but don’t always mount.

All you need is put “. /path/to/z.sh” in your ~/.zshrc or ~/.bashrc. Don’t forget to check out the README file.

Compatibility?  No worries.  The data file format and core algorithms are compatible with those of the original.  Enjoy!