Zoxide: The Smarter Way to Navigate Your Terminal
Discover zoxide, the smarter way to navigate your terminal. This comprehensive guide covers everything from the basics of zoxide, installation, and setup.
Navigating the file system through a terminal gets tedious, especially with deeply nested directories. The cd command works but requires exact path inputs and gets old fast with complex directory structures. zoxide (version 0.9.9) is a smarter, faster alternative.
The Problem with cd
The cd command has been around forever. But as projects grow and directory trees get deeper, its limitations show up. Typing out long paths is slow and error-prone. Going back to the same directories over and over with cd wastes a lot of keystrokes.
What is Zoxide?
Zoxide is a command-line tool that replaces cd for directory navigation. It’s inspired by tools like z and autojump. Zoxide supports Bash, Zsh, Fish, PowerShell, Nushell, Elvish, Tcsh, and ksh shells.
At its core, zoxide is a directory tracker. It keeps a record of the directories you visit and assigns a “frecency” score—a blend of frequency and recency—to each. This means the more often and more recently you visit a directory, the higher it ranks in zoxide database.
Key Differences from cd
Unlike cd, zoxide learns from your behavior. It doesn’t need exact path names — it predicts where you want to go based on partial inputs and your usage patterns. This makes navigation noticeably faster.
Benefits of Zoxide
The advantages of zoxide are straightforward:
- Speed: Get to any directory fast.
- Fewer Keystrokes: Type less, navigate more.
- Less to Remember: No need to memorize or type out long paths.
| Feature | cd Command | zoxide |
|---|---|---|
| Speed | Slow | Fast |
| Keystrokes | Many | Few |
| Learning Curve | None | Minimal |
| Intelligence | None | High |
With zoxide, you spend less time navigating and more time doing actual work.
For a nice Mac terminal you can also check Maximize Efficiency: Integrating Wezterm, Zoxide, and Tmux for the Perfect Mac Terminal
Installation and Setup
Installing zoxide varies slightly by platform and shell. Here are the commands for common setups:
Installation Instructions
Zoxide runs on most operating systems and shells. Here are the install commands for common setups:
| Operating System | Shell | Installation Command |
|---|---|---|
| macOS | bash/zsh | brew install zoxide |
| Linux (Debian/Ubuntu) | bash/zsh | sudo apt install zoxide |
| Linux (Arch) | bash/zsh | sudo pacman -S zoxide |
| Windows | PowerShell | scoop install zoxide or choco install zoxide |
| Any | Any | curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh |
For other operating systems or shells, please refer to the official zoxide documentation for detailed instructions.
Basic Configuration
After installing zoxide, you need to initialize it in your shell’s configuration file. This step allows zoxide to start tracking your directory usage. Below are the initialization commands for some common shells:
- Bash: Add
eval "$(zoxide init bash)"to~/.bashrc. - Zsh: Add
eval "$(zoxide init zsh)"to~/.zshrc. - Fish: Add
zoxide init fish | sourceto~/.config/fish/config.fish. - PowerShell: Add
Invoke-Expression (& { (zoxide init powershell) -join "n” })to your$profile`. - Nushell: Run
zoxide init nushell | save -f ~/.zoxide.nuand source it in your config. - Tcsh: Add
evalzoxide init tcsh“ to~/.tcshrc.
Remember, the initial learning phase of
zoxidemight seem slow as it builds its database of your most visited directories. However, this is a one-time investment that pays off with significantly faster navigation in the long run.
Verifying the Installation
To ensure zoxide has been installed and configured correctly, you can run a simple command to check its version:
zoxide --version
If zoxide is correctly installed, this command will return the current version number of the tool.
Once installed, you should have zoxide ready to go. The initial setup takes a few minutes, and the database builds itself as you use it.
Using Zoxide
Once zoxide is installed and configured, here’s how it works in practice.
Functionality
The primary command for zoxide is z. It allows you to jump to a directory using only parts of the pathname. For example, if you frequently visit /home/user/projects/my_project, you can simply type:
z my_project
Zoxide will then take you to the directory, assuming it has the highest “frecency” score for that keyword.
Examples
Zoxide is smarter than a simple search. Suppose you have two directories:
/home/user/projects/my_project/home/user/documents/my_project_report
If you’ve been working more frequently in the projects directory, a simple z my_project will take you there. But if you start working more on the report, zoxide will adapt and z my_project may start taking you to the report directory instead.
Tips for Mastery
To get the most out of zoxide, consider these tips:
- Combine
zoxidewith other tools likefzf(v0.51.0+) for interactive filtering. - Use
z -lto list directories sorted by “frecency” to see wherezmight take you. - Customize
zoxidewith environment variables like_ZO_EXCLUDE_DIRSto exclude certain directories from tracking. - Use
zoxide editto manually adjust scores for entries in the database. - Run
zoxide doctor(Bash/Zsh) to diagnose common configuration issues.
| Command | Description |
|---|---|
z <query> | Jump to the highest-ranked directory matching the query. |
z -l <query> | List all directories matching the query, sorted by “frecency”. |
z -i <query> | Interactively select a directory to jump to when there are multiple matches. |
By using these commands regularly, navigating your file system becomes much easier.
Zoxide and Zsh-Autocomplete
Pairing zoxide with zsh-autocomplete gives you both intelligent directory jumping and real-time auto-completion. This combination makes terminal navigation faster and more intuitive.
Zsh-autocomplete is a Zsh plugin that provides real-time interactive auto-completion. It suggests files, directories, and command options as you type. Less memorizing, faster typing.
Zoxide is working by default with Oh My Zsh you just need to have it installed and add zoxide. you can follow: How to Enable Command Autocomplete in ZSH and you will have both working.
Alternatives to Zoxide for Navigating the File System
zoxide is popular for good reason, but there are several alternatives worth knowing about:
Z - Jump Around
z is a command-line tool that helps you navigate to the most ‘frecent’ (frequently and recently accessed) directories using regex patterns. It’s the tool that inspired zoxide.
After a short learning phase, z will take you to the most ‘frecent’ directory that matches all of the regexes given on the command line, in order.
Autojump
autojump is a command-line tool that allows you to jump to frequently visited directories using partial names. It maintains a database of the directories you use the most from the command line.
autojump uses a self-learning algorithm to keep track of your most visited directories, enabling faster navigation through the file system.
Fzf
fzf is a command-line fuzzy finder that can be used to search for directories (and files) across your system. It’s highly customizable and can be integrated with your shell and various plugins.
fzf provides a powerful interface for searching and can be combined with other tools to enhance file system navigation.
Z.lua
z.lua is another tool that allows you to quickly jump to frequently used directories. It’s designed to be fast and integrates with a variety of shells.
z.lua is noted for its speed, claiming to be faster than autojump and z.sh. It also offers enhanced matching modes for more flexible directory jumping.
Fasd
fasd is a command-line productivity booster that offers quick access to files and directories. It’s inspired by tools like autojump, z, and v.
fasd automatically maintains a list of frequently accessed files and directories, making it easier to invoke them in the command line.
Here’s a comparison table of the alternatives:
| Tool | Description | Key Feature |
|---|---|---|
| z | Navigate using ‘frecent’ directories with regexes | Regex pattern matching |
| autojump | Jump to frequently visited directories | Self-learning algorithm |
| fzf | Fuzzy finder for files and directories | Customizable search tool |
| z.lua | Fast directory jumping | Speed and enhanced matching |
| fasd | Quick access to files and directories | Frequency-based list |
Each tool has its strengths. Pick the one that fits how you work — whether you care most about speed, fuzzy matching, or simplicity.
Conclusion
Zoxide makes terminal navigation faster by learning from your habits and predicting where you want to go. With support for nearly every shell and platform, version 0.9.9 includes quality-of-life features like the doctor command for troubleshooting, the edit subcommand for adjusting scores, and Tcsh/ksh support. Setting it up takes just a few minutes and the time savings add up quickly.
Whether you’re a seasoned terminal user or new to the command line, zoxide can noticeably speed up your navigation. Give it a try and see the difference in your daily workflow.
Zoxide also works with Fish Shell. If you’re interested in trying Fish, check out the best Fish Shell plugins (zoxide is included) or my Fish Shell vs Bash vs Zsh comparison.