zoxide Smarter cd

Version 0.10.0 · source

Start here

z <dir>
Jump to best match
z <a> <b>
Match several words
zi <dir>
Pick from a list
z -
Previous directory
z ..
Up one level
zoxide query -l
List ranked dirs
zoxide remove <path>
Forget a directory
eval "$(zoxide init bash)"
Enable in bash

Concepts

  1. cd you change directory
  2. Database paths with scores
  3. Ranking frequency + recency
  4. z / zi jump there

Setup

eval "$(zoxide init bash)"
Enable in ~/.bashrc
eval "$(zoxide init zsh)"
Enable in ~/.zshrc, after compinit
zoxide init fish | source
Enable in config.fish
zoxide init posix --hook prompt
Generic POSIX shell setup
zoxide init <shell> --cmd <name>
Rename z and zi, e.g. j and ji
zoxide init <shell> --cmd cd
Replace cd itself
zoxide init <shell> --no-cmd
Define no z or zi
The functions stay available as __zoxide_z and __zoxide_zi, so you can bind them yourself.
zoxide init <shell> --hook <hook>
When to count a visit: none, prompt, pwd
pwd (default) counts when the directory changes; prompt counts at every prompt; none never counts.

Jumping

z <keyword>
Jump to the best matching directory
z <kw1> <kw2>
Match directories containing all words
Words must appear in the path in this order; the last one must match the final path component.
z <kw> /
Jump to a subdirectory starting with kw
z <path>
Plain cd for an existing path
z -
Back to the previous directory
z ..
Up one directory
zi <keyword>
Choose among matches with fzf
z <keyword> <Space><Tab>
Show interactive completions
Works in bash 4.4+, fish and zsh; needs fzf.

Query

zoxide query <keyword>
Print the best match without jumping
zoxide query -l
List all directories, best first
zoxide query -l <keyword>
List every match for a keyword
zoxide query -ls
List with scores
zoxide query -i <keyword>
Pick interactively with fzf
zoxide query --exclude <path> <kw>
Leave one path out of the results
zoxide query --all <keyword>
Include directories that no longer exist

Database

zoxide add <path>
Add or bump a directory by hand
zoxide remove <path>
Delete a directory from the database
zoxide import --from z <file>
Import a z, fasd, z.lua or zsh-z database
zoxide import --from autojump <file>
Import autojump paths (no scores)
zoxide import --from z --merge <file>
Merge into a non-empty database
Without --merge the import fails if the database already has entries.
zoxide --version
Show the installed version

Environment variables

_ZO_DATA_DIR
Where the database lives
_ZO_ECHO=1
Print the target before jumping
_ZO_EXCLUDE_DIRS
Globs never to record, : separated
Default is $HOME, so your home directory itself is never added.
_ZO_FZF_OPTS
Extra options for fzf in zi
_ZO_MAXAGE
Entry cap that triggers aging, default 10000
_ZO_RESOLVE_SYMLINKS=1
Store real paths instead of symlinks

With other tools

zi
Interactive jump, needs fzf 0.51+
export _ZO_FZF_OPTS="--height 40% --reverse"
Compact fzf popup for zi
cd "$(zoxide query <kw>)"
Use the result in any script
ls $(zoxide query <kw>)
Inspect a directory without leaving
zoxide query -l | fzf
Browse all known directories

Recipes

Use j and ji instead of z and zi
# in ~/.bashrceval "$(zoxide init bash --cmd j)"j projji proj
Make zoxide the default cd
eval "$(zoxide init zsh --cmd cd)"cd workcd -
Move from autojump
zoxide import --from autojump ~/.local/share/autojump/autojump.txtzoxide query -l | head
Keep scratch dirs out of the database
export _ZO_EXCLUDE_DIRS="$HOME:/tmp/*"export _ZO_FZF_OPTS="--height 40% --reverse"eval "$(zoxide init bash)"