zoxide: tips and tricks
zoxide is a smart and fast alternative
to cd
that learns your directory usage patterns and allows you to jump to
directories quickly. It’s one of my favorite command-line tools and it’s an
essential part of my workflow.
Here are some tips and tricks to get the most out of zoxide:
-
Normally you’d use
z
to triggerzoxide
, but pressingz
is not super convenient. That’s why I like to usej
instead. You can set this up by adding the following to your shell configuration file (e.g.,.bashrc
,.zshrc
):alias j='z'
-
If you have
fzf
installed, thezi
command can be used to interactively select a directory to jump to. You can also usejj
withfzf
by adding the following alias:alias jj='zi'
-
zoxide
was inspired byz
andautojump
, but unlike them it’s a complete replacement forcd
. That’s why it’s not a bad idea to simply aliascd
toz
:alias cd='z'
-
If you have multiple directories with similar names you can use SPACE to trigger smart completion for your options:
z mydir<SPACE>
This will present the matching candidates (using fzf
if present), and you can
select one to jump to it.
-
If you’re a Fish user (like me), you can get nice TAB completions by installing the following Fish plugin:
fisher install icezyclon/zoxide.fish
Now try the following:
z mydir<TAB>
You can read more about the plugin here.
Note that zoxide
uses cd
internally, so switching fully to it won’t
mess with any of Fish’s internally directory stack. (e.g. dirh
and cdh
)
And that’s a wrap! Even though I do all of the above, I think the first two
items are the most important. j
and jj
are very easy to type and cover all
of my use-cases beautifully. If you have any other tips or tricks for zoxide,
feel free to share them in the comments below!
That’s all I have for you today! Keep hacking!