Jump between directories with zoxide
Jump to a directory with z and inspect the scores that zoxide uses to choose among matches.
You keep typing cd ~/code/shop/api to get back to a folder you were in an hour ago. zoxide remembers the directories you visit and jumps to one from a keyword.
Add it to your shell
Install the binary with your package manager. The README lists cargo install zoxide --locked, brew install zoxide and apt install zoxide where the package is available. Add the line for your shell to its config file and open a new shell.
# ~/.bashrc
eval "$(zoxide init bash)"
# ~/.zshrc
eval "$(zoxide init zsh)"
# ~/.config/fish/config.fish
zoxide init fish | sourceThe init code defines z and installs a shell hook that records directory changes. In Bash, run each command at the prompt so the hook can record it.
Visit directories, then jump
zoxide knows nothing on the first day, so z has no answer until you have been somewhere. Visit a few directories with plain cd, then ask for them by keyword. Substitute directories that exist on your machine for the example paths.
$ z api
zoxide: no match found
$ cd /home/you/code/shop/api
$ cd /home/you/code/shop/web
$ cd /home/you/code/blog/web
$ cd /home/you/code/shop/web
$ cd /
$ z web
$ pwd
/home/you/code/shop/web
$ z blog web
$ pwd
/home/you/code/blog/web
$ z -
$ pwd
/home/you/code/shop/webz web matched two directories and went to shop/web, the one I had visited more often. z blog web takes two keywords, and blog/web is the one that matches both. z - goes back to the directory I was in before the last jump.
Read the ranking
zoxide query -ls combines --list and --score. With no search terms, it shows the available entries and their scores, highest first.
$ zoxide query -ls
16.0 /home/you/code/shop/web
8.0 /home/you/code/blog/web
4.0 /
4.0 /home/you/code/shop/apiThe score blends how often you were in a directory with how long ago you last were. People call that frecency.
shop/web has four visits: two cd calls, one z web and one z -. Each visit adds 1 to its rank, and the score is the rank times a recency factor. Anything used in the last hour gets 4, so four visits show as 16.0.
The ranking algorithm uses a factor of 4 within an hour, 2 within a day, 0.5 within a week and 0.25 after that. A directory you stop visiting sinks in the list on its own, and one you return to climbs back.
With fzf installed, run zi web to pick a match interactively.