Introduction
If you're like me, you're constantly zipping around directories in your terminal, trying to keep up with your coding projects, side hustles, and random tech adventures. But let's be real for a second: the old cd command? It's feels like trying to navigate a maze blindfolded.
Zoxide
So, I stumbled upon this game-changing tool that's about to revolutionize the way you navigate your terminal: Zoxide. It works like magic in your terminal. It keeps track of the directories you frequently visit and ranks them based on your usage patterns. So, when you need to navigate to a directory, instead of wracking your brain trying to recall its exact path, you simply type z <directory_name>
and voila! Zoxide intelligently takes you there in an instant.
Installation
Install binary
Installing Zoxide is a breeze. You can grab it from your favorite package manager or build it from source - whatever floats your boat.
The recommended way to install zoxide is via the install script:
$ curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
I use Arch BTW, so I'll install it using pacman:
$ sudo pacman -S zoxide
Setup zoxide
Once installed, just add a tiny snippet to the end of your shell configuration file (like .bashrc or .zshrc), and you're good to go!
For bash (~/.bashrc
):
eval "$(zoxide init bash)"
For fish (~/.config/fish/config.fish
):
zoxide init fish | source
For zsh (~/.zshrc
):
eval "$(zoxide init zsh)"
Usage
https://github.com/ajeetdsouza/zoxide/wiki/Algorithm
You can find out more about Zoxide on its man page after installed:$ man zoxide
To unlock its full potential, it's a good idea to train it. Training Zoxide involves simply using your terminal as you normally would for a bit, letting Zoxide observe your directory navigation patterns. Try navigating to your projects with Zoxide.
After training, using Zoxide is as easy as typing z <directory_name>
to quickly navigate to frequently accessed directories without the full path!
Rebinding
Now, Zoxide is incredible, no doubt about it. But what if you're a creature of habit, like me, who's been typing cd for eons?
You can easily rebind the z
command to cd
, so you don't have to mess with your muscle memory:
For bash (~/.bashrc
):
eval "$(zoxide init --cmd cd bash)"
For fish (~/.config/fish/config.fish
):
zoxide init --cmd cd fish | source
For zsh (~/.zshrc
):
eval "$(zoxide init --cmd cd zsh)"
Conclusion
In short, Zoxide is your terminal's new best friend, guiding you effortlessly through directories with just a few keystrokes. Say goodbye to aimless navigation and hello to smooth sailing with Zoxide!
PS: This is my first blog, so your feedback means the world to me!
Top comments (10)
I don't particularly like learning commands which enhance (or worse, shadow) existing commands, because I worry I'll lean on their behaviour in a script or on a foreign system and cause something bad to happen.
My issue with Zoxide is that I use a lot of directories with similar names in parallel hierarchies. Lots of similar projects.
When I have to type
pwd
after every directory change, or create an alias/function to do that for me, and devote extra braincells to pausing and checking before running the next potentially destructive command, I lose productivity.I don't even like using
CDPATH
- and that's part of POSIX!But if it works for you, great :)
I immediately think of
adduser
as extension touseradd
Nice article. Straight forward without a lot of preamble or hyperbole. Though in the future you might want to give examples for installation on multiple distros such as Fedora and Ubuntu for people not so familiar with Gnu/Linux.
For instance to install on Fedora 39:
and of course add:
to your .bash_profile or .bashrc file.
You could also mention that they can find out more about zoxide on its man page after installed.
I like the way you included information about other shells. Good job.
Looking forward to your future articles.
Take Care
Thank you so much, I'll take this into consideration.
If you're really adventurous you can try rpg-cli
Haha, thanks for this! I didn't know it existed.
Neat - thanks for posting. I'm trying it out - looks good.
Intresting post
Zoxide is a great tool. I'm using it for years, and I couldn't leave without it
zoxide f* rules.