Do you ever get tired of navigating directories back and forth? I am 100% sure that the answer will be yes, and at that point, you will launch multiple windows and operate them all at once.
Suggestion: Ranger: Terminal File Manager inspired by VIM for Linux
What if I told you that you could have a single window and dynamically navigate through multiple directories without specifying the full path? Yes, it’s true, and you achieve this by using autojump in Linux.
Table of Contents
What is Autojump in Linux?
Autojump is a Linux command line program that helps you easily navigate directories back and forth with long paths by just specifying the directory name.
How is this possible? The mechanism is very easy to understand. When you load autojump
in your shell, it will store all your inputs with the cd command in its own database.
In the future, when you specify the directory name using the autojump
command, it will directly navigate you through the directory without specifying the full path.
How do I Install Autojump on Linux?
The good news is, autojump
is available in major Linux distribution repositories, including macOS. Execute any of the below commands depending upon your distribution type to install autojump
on Linux.
Suggestion: Top Debian-based Linux Distributions
$ sudo apt install autojump #For Ubuntu, Debian, Linux Mint, Pop!_OS
$ sudo dnf install autojump #For RHEL, Fedora, AlmaLinux, CentOS
$ yay -Sy autojump #For Arch, Manjaro, EndeavourOS
Homebrew is the recommended installation method for macOS:
$ brew install autojump
In addition to the distribution package manager, you can install it as a plugin if you are using zsh or fish shell. Install autojump-zsh
for zsh, autojump-fish
for fish, etc.
How to Configure Autojump on Linux?
Autojump will not work unless you activate it in your shell. There are two ways to activate it: temporary and permanent.
Temporary changes will only be effective until the current session is closed. While the permanent will work even after the new terminal session is started. Both methods are shown below.
Autojump temporarily loads in your shell
$ source /usr/share/autojump/autojump.sh
Autojump permanently loads into your shell
$ echo "source /usr/share/autojump/autojump.sh" >> ~/.bashrc
How to Check Whether Autojump is Working on Linux?
Once the installation and configuration part is done, you can verify the version of the Autojump by using the autojump
or j
commands, as shown below.
$ autojump -v
OR
$ j -v
Below is the output of the above command.
Note: Both commands are similar and can be used in the opposite order. However, it’s interesting to know that the j
command is a wrapper around Autojump.
How to Use Autojump on Linux?
For demonstration purposes, I’ll first navigate through some directories including the system and manually created by me, as shown below.
Also Read: Walk: A Lightweight Terminal Navigator
As you navigate through directories from their full paths, autojump
will record the full paths in its database for future use. It will make it easy for you to navigate back and forth in the directory without needing a full path.
Suggestion: Monitor CPU Thermal Temperature in Linux
#Example One
Let’s go back to the /var/ww/html
path without specifying the full path using the following command.
$ j html
Below is the output of the above command.
#Example Two
Jumping to the child directory (sub-directory of the current directory) of ~/parentdir/
path.
$ jc parentdir
Below is the output of the above command.
#Example Three
Instead of jumping to a directory, you can open the path in the distribution file manager like Nautilius for GNOME.
$ jo html
Below is the output of the above command.
#Example Four
To open a child directory in the file manager.
$ jco parentdir
Below is the output of the above command.
Where is the Autojump Database?
You can execute the below command to view the database entries and their key weights stored in the Autojump database.
$ j --stat
Below is the output of the above command.
However, you can directly navigate to the ~/.local/share/autojump/
configuration path from where all the input records and error logs are stored.
Note: Do not modify the configuration file, otherwise you might lose all of your database entries.
Known Issues
For bash users, autojump keeps track of directories by modifying $PROMPT_COMMAND
. Do not overwrite $PROMPT_COMMAND
:
export PROMPT_COMMAND="history -a"
Instead, append this to the end of the existing $PROMPT_COMMAND
:
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} history -a"
For any questions, open a GitHub issue:
Innovative tech mind with 12 years of experience working as a computer programmer, web developer, and security researcher. Capable of working with a variety of technology and software solutions, and managing databases.