LinuxCommandLibrary

autojump

Quickly jump to frequently used directories

TLDR

Add the autojump aliases to your shell

$ source /usr/share/autojump/autojump.[bash|fish|zsh]
copy

Jump to a directory that contains the given pattern
$ j [pattern]
copy

Jump to a sub-directory (child) of the current directory that contains the given pattern
$ jc [pattern]
copy

Open a directory that contains the given pattern in the operating system file manager
$ jo [pattern]
copy

Remove non-existing directories from the autojump database
$ j --purge
copy

Show the entries in the autojump database
$ j [[-s|--stat]]
copy

SYNOPSIS

autojump [options] [query]
j [options] [query]
j -s
j --stat

PARAMETERS

[query]
    The partial name or fragment of the directory you wish to jump to. autojump will use fuzzy matching to find the best match based on its learned database.

-s, --stat
    Displays statistics about the autojump database, including the total number of entries and usage frequency.

--add <path>
    Manually adds a specified path to the autojump database. This is useful for directories that might not be frequently `cd`ed into but are important.

--purge
    Removes non-existent directories from the autojump database, cleaning up stale entries.

-h, --help
    Shows the help message and available options.

-v, --version
    Displays the current version of autojump.

DESCRIPTION

autojump is a free, open-source command-line utility that allows users to navigate the filesystem faster by learning their habits. Instead of typing out long paths with `cd`, autojump tracks directories visited using the `cd` command and builds a database based on frequency and recency.

When a user types `j` followed by a partial directory name, autojump uses fuzzy matching to jump to the most probable directory. For instance, `j proj` might take you to /home/user/documents/work/my_project. This significantly reduces typing and improves productivity for developers and power users who frequently switch between many directories. It integrates seamlessly with popular shells like Bash, Zsh, and Fish, providing an intuitive and adaptive way to move around the command line.

CAVEATS

autojump requires shell integration (e.g., sourcing `autojump.bash` or `autojump.zsh`) to function correctly. This is usually handled during installation.
It only tracks directories you navigate to using `cd`. Directories visited via other means (e.g., GUI, `pushd` without a subsequent `cd`, `sudo cd`) are not automatically added.
The effectiveness of autojump improves over time as it learns your navigation patterns. It might not be immediately useful after a fresh installation.
Fuzzy matching can sometimes lead to unexpected jumps if multiple directories have similar names and similar scores.

<I>INSTALLATION AND SHELL INTEGRATION</I>

To use autojump, it must be installed via your distribution's package manager (e.g., `apt install autojump` on Debian/Ubuntu, `pacman -S autojump` on Arch). After installation, you need to ensure that the appropriate shell script (e.g., `autojump.bash` for Bash, `autojump.zsh` for Zsh) is sourced in your shell's configuration file (e.g., `~/.bashrc`, `~/.zshrc`). This typically involves adding a line like `[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && source ~/.autojump/etc/profile.d/autojump.sh` or similar, depending on the installation method.

<I>USAGE EXAMPLES</I>

To jump to a directory whose path contains "documents": j doc
To jump to a directory that's a subfolder of "projects" and contains "blog": j pro blog
To display current database statistics: j -s
To add the current directory to the database without `cd`ing: j --add .
To clean up non-existent entries: j --purge

HISTORY

autojump was created by Leo Hsu, initially released around 2010. It emerged as a solution to streamline command-line navigation, addressing the repetitive nature of typing long directory paths. Its design philosophy centered on simplicity and intelligent learning, quickly gaining popularity among Linux and macOS users for its efficiency gains. The project is open-source and has seen continuous development and contributions from the community, ensuring compatibility with various shells and ongoing improvements to its fuzzy matching and scoring algorithms.

SEE ALSO

cd(1), pushd(1), popd(1), fasd(1), zoxide(1)

Copied to clipboard