hr.thin {
border: 0;
height: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
Overview
I like the idea that there are tools available to enhance the
'cd' command, remembering places you have been in the file
system and taking you there easily.
I use 'pushd'
and 'popd' for moving in and out of directories from a
place I want to do most of my work, but something more powerful than
these or cd have always seemed desirable.
I was using 'autojump' for a while last year, but didn’t
really get on with it. This was mainly because there was no way of
excluding certain directories which had been visited from its list.
Recently I heard of 'zoxide', which I have been trying
and really like.
zoxide
What is it?
From the GitHub
page:
zoxide is a smarter cd command, inspired by z1 and
autojump.
It remembers which directories you use most frequently, so you can
“jump†to them in just a few keystrokes. zoxide works on all major
shells.
In its man page it’s billed as “A faster way to navigate your
filesystemâ€.
It’s written in Rust so is very fast.
What does it do?
It offers the functionality of the Linux/Unix 'cd'
command.
It collects the directories you have visited into a database and
gives them a ranking relating to the number of times they have been
visited. It applies aging rules and removes these when the ranking drops
below one. It uses frecency to do this - a combination of
frequency and recency. (See the Wikipedia page
explaining this word)
It performs algorithmic matching on the directory you specify and
takes you to the highest ranking best match.
It can resolve conflicts between matching directories or can
allow selection through an interactive interface.
It can interface to fzf, a general-purpose
command-line fuzzy finder.
It “knows†where it is (in the Bash shell) by calling a function
out of the PROMPT_COMMAND variable. This can be used to
execute one or more commands before displaying the prompt for a new
command. This is a common way to hook monitoring commands into
a Bash session.
Where can you get it?
I installed it from the Debian Testing repo, but I got
'zoxide v0.4.3-unknown' whereas the latest version is
0.9.0. Installing from the GitHub page seems the
best option if you want the latest version.
There is an installation script on the GitHub page and it’s possible
to download it with curl and pipe it to Bash. I’m never
comfortable doing this, but that’s your choice.
I also installed fzf from the Debian Testing repo,
though I’m still learning what this can do, since it’s very rich in
features!
How do you set it up?
This process is shell-specific. I run Bash so I have added it to my
~/.bashrc and the command there is:
eval "$(zoxide init bash)"
What this does is generate a number of Bash functions and aliases and
some commands which are fed into eval and executed in the
current context.