VibeHunt
Back to browse

z.lua

`cd` command that learns your habits.

Source

z.lua is a command‑line utility that records the directories you visit and uses a “frecency” metric to predict which location you want to jump to next. After a brief learning period it lets you type a few keywords, and it changes to the most frequently and recently used directory that matches all of them in order. The tool works with POSIX shells, Fish, Nushell, PowerShell and Windows cmd, and can be invoked with options for interactive selection, listing matches, or restricting the search to subdirectories of the current working directory.

The implementation is a single Lua script that requires no external dependencies, though an optional native C module can be loaded for additional speed. It includes an enhanced matching algorithm, optional integration with FZF for interactive completion, and a mode that updates its database only when the working directory changes. Compatibility with Lua 5.1‑5.3 and LuaJIT makes it usable on a wide range of systems, including Raspberry Pi and WSL.

Typical usage examples are `z foo` to cd to the best match for “foo”, `z foo bar` for a combined pattern, `z -i foo` for an interactive chooser, and `z -l foo` to list candidates without changing directories. The script can be initialized in shell startup files with a simple `eval "$(lua /path/to/z.lua --init …)"` command, optionally enabling enhanced matching or FZF support.

Reviews

Sign in to leave a review.

Loading reviews…

Similar apps