What’s Zoxide? #
Zoxide
is a CLI tool that replaces the default cd command. At first, it
doesn’t seem much different from cd, but after using it for a while,
it remembers the paths you’ve navigated to, and allows you to jump to them much
faster. That’s the main goal of
Zoxide
and why it’s so useful.
Here’s an example of a daily workflow you may have:
You have several projects throughout your day, and you navigate to them using absolute paths. It’s quite time-consuming, but that’s the common way to do it.
With
Zoxide, instead of typing the absolute path every time, you simply type parts of the path. If
your project is located at /Users/myname/projects/my-client/website/shop,
using
Zoxide, you can simply write z shop, and voilà!
Maybe you have multiple projects with the name shop? No worries, you can
use z client shop to add a new layer of precision. To simplify, you can use
any words presents in the path, and you can use an unlimited number of parameters to
increase the precision.
Installation #
The installation will depends on your OS. That’s why, I recommend you to take a look at the documentation here: install Zoxide.
Or, as Homebrew is a popular package manager, here is the command to install Zoxide with it:
brew install zoxide
Configuration #
In this section, we will configure Zoxide to work with the three common shells.
Please add the corresponding command at the end of the file.
Bash #
In your .bashrc file, add the following:
eval "$(zoxide init bash)"
Zsh #
In your .zshrc file, add the following:
eval "$(zoxide init zsh)"
Fish #
In your config.fish, in general it is located in
~/.config/fish/, add the following:
zoxide init fish | source
Replace the cd command
#
It is possible to replace the cd command. To do so, in the previous step,
when initializing
Zoxide, add the parameter --cmd cd.
For example:
eval "$(zoxide init bash --cmd cd)"
Reload your shell, and now cd will invoke
Zoxide
instead of the default cd command.
The cdi command #
If you replace the cd command, it will provide a cdi command.
The letter “i” stands for “interactive”.
It opens an interface and allows you to search paths, like you would do with
cd, but you can visualize all paths found with the scores attributed.
This command requires installing fzf first. It’s a command for fuzzy
searching.
As always, Homebrew will be your best friend!
brew install fzf
Conclusion #
You discovered one of my favorite tool, and a fun way to save time!
Happy jumping!
Thank you for reading me. If you enjoyed this article and consider offering me a ☕, I will be very grateful, and it will help me write new articles.