Stop typing long directory paths. Start using the zoxide command.
If you spend any time in the terminal, you know the pain. You cd into the same nested directories over and over. Projects, config folders, log directories. Every time you type the full path or hit Ctrl+R to find that one directory from three hours ago.
The zoxide command fixes this. It remembers where you go and builds a database of your most-used directories. After that, you jump around with just a few characters. No more tab-completing through five levels of nesting.
I switched to zoxide last year and the zoxide command is one of those tools I miss immediately when I use a machine without it. Here are 10 ways to use the zoxide command that cover everything from basic setup to advanced tricks.
1. Install zoxide on Any Linux Distro
The zoxide command is available in most package managers. Pick your distro:
# Debian / Ubuntu
sudo apt install zoxide
# Arch Linux
sudo pacman -S zoxide
# Fedora
sudo dnf install zoxide
# macOS (Homebrew)
brew install zoxide
After installing, add one line to your shell config. This is the most important step because without it zoxide does nothing.
# For bash — add to ~/.bashrc
eval "$(zoxide init bash)"
# For zsh — add to ~/.zshrc
eval "$(zoxide init zsh)"
# For fish
zoxide init fish | source
Restart your shell or source the file. Now every cd you type gets tracked.
2. Basic Navigation with the zoxide command
The zoxide command gives you a few subcommands, but the main one is just z. It works like a smarter cd. The first time you visit a directory, use regular cd or z with the full path. After that, zoxide remembers it.
# First visit — use full path
cd ~/projects/my-web-app/src/components
# Next time — just type part of the name
z components
zoxide scores directories by frecency (frequency + recency). The directory you visit most often and most recently ranks highest. So typing z proj takes you to your most-used project directory, not just the first alphabetical match.
This is the core workflow. One word instead of a long path.
3. Jump to a Subdirectory with z
You can also append a subdirectory name. The zoxide command matches the parent directory first, then cd’s into the child path you specify.
# Jump to ~/projects/my-web-app/logs
z my-web-app logs
This is useful when you have multiple projects with similar structures. z my-web-app logs takes you to the logs folder of my-web-app, even if you also have an api-gateway project with a logs folder.
4. Interactive Selection with zi
Sometimes zoxide finds multiple matches. When that happens, the zi command shows an interactive picker using fzf (if you have it installed).
# If you have multiple "config" directories
zi config
This opens a fuzzy search list. Start typing to narrow it down, press Enter to pick. If you don’t have fzf installed, zi falls back to printing the top match.
I use this constantly. It turns directory navigation into a search operation instead of a memory exercise.
5. Remove a Directory from the Database
Sometimes you want zoxide to forget a directory. Deleted projects, temp folders, directories you visited once by accident. Use the --remove flag:
# Remove a specific directory
zoxide remove ~/old-project/build
# Remove the current directory
zoxide remove "$(pwd)"
You can also query the database to see what zoxide has stored:
# List all directories in the database
zoxide query -l
This shows every path zoxide tracks, sorted by score. Useful for auditing.
6. Use zoxide as a Drop-in cd Replacement
If you want the zoxide command to replace cd entirely, use zoxide init --cmd cd instead of the default. This binds the zoxide command logic directly to the cd command.
eval "$(zoxide init --cmd cd bash)"
Now typing cd proj jumps you to your most-used project directory. Regular cd path navigation still works. If the argument is an actual directory path, zoxide passes it through. If it’s a fuzzy match, it jumps.
I personally keep z as a separate command because I like having both. But the drop-in mode is cleaner for people who want one less command to remember.
7. Integrate zoxide with fzf for Full Control
If you use fzf (we have a full guide here), the two tools work together beautifully. The zi command already uses fzf when available, but you can customize the behavior.
# Set a custom fzf command for zoxide
export _ZO_FZF_OPTS="--preview 'ls -lah {}' --preview-window=right:60%"
# Now zi shows a preview pane with directory contents
zi
This is one of my favorite setups. Type zi, see a live preview of each directory’s contents, pick the one you want. It turns navigation into a visual browsing experience.
8. Use zoxide with Common Shell Workflows
The zoxide command works inside scripts and shell expansions too. This is useful for one-shot commands:
# Run a command in a zoxide-matched directory
cd $(zoxide query my-project) && docker-compose up -d
# Open a file in your project
vim $(zoxide query my-project)/config/settings.yaml
# Tar a directory without cd'ing into it first
tar -czf backup.tar.gz -C $(zoxide query data-dir) .
These patterns save a lot of time in daily work. Instead of navigating somewhere and running a command, you inline the navigation using the zoxide command.
9. Manage the zoxide Database
Over time your zoxide database grows. You can add directories manually, import from other tools, or prune entries.
# Add a directory manually
zoxide add /var/log/nginx
# Import from z or autojump databases
zoxide import /path/to/z/data
# Query with a minimum score threshold
zoxide query -l --score 10
The database lives at ~/.local/share/zoxide/db.zo by default. It’s a small binary file. You can back it up or sync it between machines if you want portable directory history.
10. Boost Productivity with zoxide command Aliases
Power users set up shortcuts for common navigation patterns. Here are a few I use:
# Jump to your home config directory
alias zconf='z ~/.config'
# Jump to the Downloads folder
alias zdl='z ~/Downloads'
# Jump to your most-used project
alias zproj='z projects'
# Interactive picker with preview
alias zp='zi'
Combine these with the zoxide command and you barely type paths anymore. Your shell learns your patterns and adapts to them.
Why the zoxide command Beats Plain cd
Regular cd works fine for simple navigation. But once your workflow involves more than a few directories, the mental overhead adds up. You remember paths, you tab-complete through trees, you hit the same sequence of keys every day. The zoxide command removes that overhead.
It learns from your behavior. After a week of using the zoxide command, the database reflects your actual workflow. The directories you visit most are the ones that appear first. No configuration needed.
For more modern CLI tools, check out our guides on bat (a cat replacement with syntax highlighting) and fd (a faster, simpler find alternative). The Rust-based tool ecosystem is changing how we use the terminal, and zoxide is one of the best examples.
The official zoxide documentation is on GitHub with detailed setup guides for every shell. The Linode docs also have a solid walkthrough for beginners.