Skip to content
C.W.K.
Stream
Lesson 03 of 08 · published

zoxide: Smart cd

~8 min · zoxide, cd, frecency

Level 0Window Tourist
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

cd, but it remembers

zoxide learns which directories you visit and ranks them by frecency (frequency × recency). After a day or two, z proj jumps straight to ~/projects/notes without typing the path.

Install and hook

brew install zoxide
echo 'eval "$(zoxide init zsh)"' >> ~/.zshrc

By default it adds the z command. zi opens an interactive picker (uses fzf if installed).

Daily use

z notes            # jump to highest-ranked dir matching 'pippa'
z notes archive       # match multiple substrings
z -                 # previous directory (like cd -)
zi note              # interactive picker

Database

Stored at ~/.local/share/zoxide/db.zo. Survives reboots. zoxide query --list --score shows your ranked dirs. zoxide remove path drops a dir from the database.

How it pairs with autocd

If you have setopt AUTO_CD in zsh, you can also drop the cd: typing ../sibling jumps. Combined with zoxide's substring jumps, you barely type cd at all anymore.

Frecency is a prediction

When several directories match, zoxide chooses from learned history. Query and print the resolved path before destructive work, and keep exact paths in automation.

Keep exact and learned navigation distinct

Using z beside the shell's original cd makes the contract visible. Avoid a hand-written alias that silently changes established cd behavior.

Navigation history is personal data

Learned paths can reveal project, customer, and host names. Review storage, sync, and reset behavior before sharing the database or enabling synchronization.

Frecency compresses habits

That compression is useful for interactive movement, not a stable identifier. Keep exact paths in scripts and verify the resolved directory before destructive work.

Code

Bootstrap zoxide·bash
brew install zoxide
echo 'eval "$(zoxide init zsh)"' >> ~/.zshrc
exec zsh
# Visit a few directories, then
z proj

External links

Exercise

Install zoxide and add the eval line. Visit a handful of project dirs over an afternoon. Then z to a partial name. Run zoxide query --list --score and watch the rankings.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.