Basics of AutoJump
Let us assume we have two directories named “Alan” and “bob”. So if we have to jump to a directory alan, the following command is used.
j alan
You can jump to a sub-directory without typing out the entire directory name using the following command.
jc bob
One can also open the Operating System’s file explorer instead of jumping to the directory.
jo pictures
The same is also applicable for child directories.
jco images
Multiple Arguments
Let us assume the following directories along with their weights.
40 /home/user/mail/inbox
20 /home/user/work/inbox
You can influence the behavior of the “autojump” command by providing multiple arguments. For instance, if you want to prioritize a different entry, such as “work” over “mail,” you can use the command “j w in” instead of just “j in.” With “j w in,” the directory will change to “/home/user/work/inbox,” considering your preference for the “work” directory over the “mail” directory as the higher-weighted choice.
Example
AutoJump becomes operational only after you’ve visited a directory; in other words, you need to visit a directory at least once before jumping to it. Let us create some sample directories and visit them before testing AutoJump. You can either use “autojump” or “j” to use AutoJump, “j” is a convenience wrapper function around autojump. Any option that can be used with “autojump” can be used with “j” and vice versa.
$ mkdir -p geek/for/
$ mkdir -p g/f/g/
$ cd geek/for/
$ cd ~
$ cd g/f/
$ cd ~
To check the weights of the visited directories use the following command.
$ j -s
To jump to a directory use the following command.
$ j <directory-name>
To jump to a child directory that is within, use the following command.
$ jc
Use the following command to jump to the directory and as well as open it in the file explorer.
jco geek/
To learn more about AutoJump and the available commands use the below command.
autojump --help
If u delete any directory, the weights will remain in the Autojump records. So once you remove any directory it must be purged from the log file. To do this execute the following command.
$ j --purge
Setting weight to the directories
You can increase or decrease the weight of a directory using the “-i” and the “-d” flag. This will alter the priority of the directories cause the weights directly affect the priority of the directories.
j -i [WEIGHT]
j -d [WEIGHT]
Autojump – An Advanced ‘cd’ Command to Quickly Navigate Linux Filesystem
The AutoJump is a command-line utility tool that helps us to navigate the file system more efficiently by quickly jumping to recently visited directories. AutoJump keeps a record of directories previously accessed by the user thus we will be able to switch between the directories swiftly instead of the traditional way of traversing it through the hierarchy. This is achieved by keeping track of the directories visited by the user and assigning importance or “weight” to the directories based on factors such as the time spent by the user.
Check out the official GitHub repository of AutoJump here: https://github.com/wting/autojump. This article will guide you through the installation as well as the usage of AutoJump.