Jump! Quick directory change at the command line
Database Based
You can easily jump into directories that autojump keeps in its database using the j
wrapper. For example, j Dow
would take you to the ~/Downloads
directory. In the same way, j loa
also takes you there. The depth of the directory hierarchy is not important; the main thing is that you visited the desired directory at least once using cd
.
If you want to switch to your file manager for a better overview, jo Dow
opens the directory for Plasma in Dolphin or for Gnome in Nautilus (Figure 2). If you just enter j
, the command jumps to the most frequently visited directory, for which Autojump uses internal weighting.
If you call the content of the database with j --stat
, you will see different numbers in front of the respective paths, for example:
22.4: /home/devil/Downloads/piwik
This sequence of digits is the internal weighting (Figure 3). As an example, the following directories are in the database:
If you enter j in
, high weighting causes autojump to switch to /home/user/mail/inbox/
, whereas j w in
would be the correct command to access the lower weighted directory. You can use the --increase
(-i
) and --decrease
(-d
) parameters to change the weighting, and j --help
for additional information about syntax.
Alternatively, if you have several similar directories, you can display the numbered entries by means of tab-based autocompletion and then select the corresponding entry by number.
A helpful tip when using autojump: Sometimes the database suddenly empties, which can be extremely annoying, because you then have to start indexing from scratch. Sometimes it is better to back up the database manually.
Turbo
Fasd [4], the final tool covered in this article, was inspired by autojump. However, the software exceeds its role model: Fasd no longer restricts the navigation options to the directory tree, and it also indexes the data. Fasd works with the Ash, Bash, Zsh, mksh, pdksh, dash, and BusyBox shells under Linux, as well as /bin/sh
in FreeBSD 9 and OpenBSD.
Fasd lets you open files by entering just a few characters in Vim or your default editor. You can view PDFs or play movies and music with MPlayer or your favorite player. The letters in the Fasd acronym stand for predefined aliases that process different types of data.
When you enter f
, the tool shows you the visited files, including their weighting. Entering d
provides the same result for the directories, and a
lists both. zz
takes you to a view in which you select an entry by the prefixed number (Figure 4).
Defining additional aliases lets you open various files: for example, PDFs (Figure 5). In turn, you can create the following proxy in .bashrc
:
alias o='a -e xdg-open'
Now source the file, as shown in Listings 2 and 3. The following also applies: Like autojump, Fasd only detects objects that have already been indexed.
Movies and music also can be started with just a few keystrokes. For this to work, enter
alias m='f -e mplayer'
in .bashrc
. Alternatively, use a different player or change the m
call switch to another. Then, simply start the movies or music using m<part of title>
.
Like autojump, Fasd also lets you use letters from the middle of the name. The aliases' structure is simple: -e
stands for execute. For files, select f
; for directories, d
. If the alias includes both, as with xdg-open [5], select a
. On GitHub, the project provides an overview of the tool's many other possibilities.
Conclusions
All three tools presented in this article have one thing in common: They do not run in drop-down terminals, such as Yakuake or Guake, just in consoles or terminals. However, you will not read this anywhere, which led to me occasionally doubting the tools' capabilities in the lab. All three helpers are meaningful, and they build on each other.
If you do not constantly work at the command line, bd makes it easy to navigate without having to learn something new. Autojump offers much more and jumps into directories in random directions. This suits the workflow of users who frequently work on servers and like to handle administrative work at the command line. After the introduction phase, autojump saves some time here.
Fasd expands the feature set again, because it also indexes files and thus takes control of all the files on the computer. It also offers professional options to further customize the approach to suit your own needs.
Infos
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs