Skip to content

zoxide - Smarter cd Replacement Cheatsheet

zoxide - Smarter cd Replacement Cheatsheet

Section titled “zoxide - Smarter cd Replacement Cheatsheet”

A smarter cd command that learns your most-used directories and lets you jump to them with just a few keystrokes. Uses a “frecency” algorithm combining frequency and recency of visits.

PlatformCommand
macOS (Homebrew)brew install zoxide
Ubuntu/Debiansudo apt install zoxide
Arch Linuxsudo pacman -S zoxide
Fedora/RHELsudo dnf install zoxide
Windows (Winget)winget install ajeetdsouza.zoxide
Windows (Scoop)scoop install zoxide
Windows (Chocolatey)choco install zoxide
Cargo (All platforms)cargo install zoxide --locked
Condaconda install -c conda-forge zoxide
Nixnix-env -iA nixpkgs.zoxide
Install scriptcurl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh

Add the appropriate line to your shell config file:

ShellConfig FileCommand to Add
Bash~/.bashrceval "$(zoxide init bash)"
Zsh~/.zshrceval "$(zoxide init zsh)"
Fish~/.config/fish/config.fishzoxide init fish | source
PowerShellProfileInvoke-Expression (& { (zoxide init powershell | Out-String) })
Elvish~/.elvish/rc.elveval (zoxide init elvish | slurp)
Nushellenv.nuzoxide init nushell | save -f ~/.zoxide.nu
Xonsh~/.xonshrcexecx($(zoxide init xonsh))
CommandDescription
z fooJump to highest-ranked directory matching “foo”
z foo barJump to directory matching both “foo” and “bar”
z ~/projectsJump to exact path (works like regular cd)
z ..Go up one directory
z -Return to previous directory
zi fooInteractive selection with fzf (when multiple matches)
ziInteractive selection from all tracked directories

zoxide matches directory paths by keywords. You don’t need to type the full path:

# If you frequently visit /home/user/projects/my-app
z my-app      # Jumps directly there
z proj app    # Also works (matches both words in path)
z app         # Works if it's your most frequent "app" directory

Scoring: Directories get points when visited. Recent visits score higher. Unused directories decay over time.

CommandDescription
zoxide add /path/to/dirManually add a directory to the database
zoxide remove /path/to/dirRemove a directory from the database
zoxide editOpen database in $EDITOR for manual editing
zoxide query fooShow the best match for “foo” (without jumping)
zoxide query -lList all directories in database, sorted by score
zoxide query -l fooList all matches for “foo” with scores
zoxide query -ls fooList matches with scores, sorted by score
zoxide query -i fooInteractive selection mode

Migrating from another directory jumper? Import your database:

CommandDescription
zoxide import --from=autojump /path/to/dbImport from autojump
zoxide import --from=z /path/to/dbImport from z/z.sh
zoxide import --from=fasd /path/to/dbImport from fasd

Default database locations to import:

  • autojump: ~/.local/share/autojump/autojump.txt
  • z: ~/.z
  • fasd: ~/.fasd
VariableDefaultDescription
_ZO_DATA_DIRPlatform-specificDirectory to store the database
_ZO_ECHO0Print matched directory before navigating (1 to enable)
_ZO_EXCLUDE_DIRSNoneDirectories to exclude (colon-separated paths)
_ZO_FZF_OPTSNoneCustom options passed to fzf in interactive mode
_ZO_MAXAGE10000Maximum number of entries in the database
_ZO_RESOLVE_SYMLINKS0Resolve symlinks before storing paths (1 to enable)
OptionDescription
--cmd jChange command name from z to j (creates j and ji)
--hook promptUpdate scores on every prompt (default)
--hook pwdUpdate scores only when directory changes
--hook noneNever auto-update scores
--no-cmdDon’t create z and zi aliases (use __zoxide_z directly)
# Example: use 'j' instead of 'z', update on directory change only
eval "$(zoxide init bash --cmd j --hook pwd)"
# Exclude home directory and tmp from tracking
export _ZO_EXCLUDE_DIRS="$HOME:/tmp:/private/tmp"
# Use custom fzf preview
export _ZO_FZF_OPTS="--preview 'eza -la --icons {2..}' --preview-window=right:40%"
# Jump to a project directory by partial name
z myproject

# Disambiguate with multiple keywords
z work api          # matches ~/work/projects/api-server

# Interactive mode when you're not sure
zi deploy           # opens fzf with all matching directories

# Check what zoxide thinks is the best match
zoxide query deploy

# See all tracked directories and their scores
zoxide query -ls

# Clean up deleted directories from the database
zoxide query -l | while read -r line; do
  dir=$(echo "$line" | awk '{print $2}')
  [ ! -d "$dir" ] && zoxide remove "$dir"
done

When you use zi, zoxide automatically uses fzf for interactive selection. Make sure fzf is installed for this to work.

zoxide provides tab completions. After shell integration, pressing Tab after z will suggest matching directories.

Featurecdzoxide (z)
Go to exact pathcd /full/pathz /full/path
Partial matchingNoYes (z proj)
Frecency rankingNoYes
Interactive selectionNoYes (zi)
Previous directorycd -z -
Learning behaviorNoLearns from usage
Database importN/Aautojump, z, fasd
IssueSolution
z command not foundEnsure shell integration line is in your shell config and restart shell
No matches foundVisit directories with cd first — zoxide learns over time
Wrong directory matchedUse more specific keywords: z work api instead of z api
Database too largeLower _ZO_MAXAGE or run zoxide edit to clean up