The autojump command does just that, it learns. But if you are looking for AI or ML then move on, nothing to see here. Autojump can be used as a substitute for the cd change directory command. It can make CLI usage more flexible if you adapt it. This entry is about the autojump configuration for the zsh shell.

Install autojump using emerge:

user % emerge -va autojump

A post installation notification is displayed at the end of the installation routine , showing a configuration example for the fish shell:

* If you use app-shells/fish, add the following code to your
* config.fish to get autojump support:
* if test -f /usr/share/autojump/autojump.fish
*     source /usr/share/autojump/autojump.fish
* end

Apparently the ebuild writer or the autojump autor are fans of the fish shell. Well how then configure this tool for ZSH? Most probably the configuration example displayed ships already some useful hints.

Put following line into the the .zshrc configuration file in the home directory, i have been unable to find the proper ikiwiki tag or escape sequence to display following one-liner that needs to be added, it could not display the double square bracket. Well a good enough solution, add these lines to your .zshrc configurition:

Finally after editing, write the changes, and source the ~/.zshrc for the current shell:

user % source ~/.zshrc

Or open a new shell which will load the updated .zshrc file from the home directory. There might be issues if the command j is already configured as an alias. Current aliases are displayed by using the alias command, in the example below there is already an alias defined which would need to be de-configured before using the autojump command.

user % alias

run-help=man which-command=whence j=jobs -l

Now as everything works, instead of using the cd command to change to a directory, use from now on the command j. J like jump, j is an alias for the autojump command.

Display current autojump statistics:

user % j -s

10.0: /usr/src/linux 10.0: /opt


20: total weight 2: number of entries 0.00: current directory weight data: /home/user/.local/share/autojump/autojump.txt

Each jumppoint or directory receives an initial value of 10.0 in the statistic. The rest of the statistics file is self-explanatory. Review the stats after some hours of using autojump. The statistics hold 2 jump entries /usr/src/linux and /opt. These entries will be used in following examples below.

Here some easy autojump usage examples. For example jump to the linux directory:

user % j linux /usr/src/linux

If the scoring of a directory needs further adjustments, then jump to the desired directory and alter the directory weight using the -i --increase or the -d arguments:

user % j opt
user % j -i 26.5: /opt

A full help information page for autojump is displayed using the -h --help option:

user % j -h

usage: autojump [-h] [-a DIRECTORY] [-i [WEIGHT]] [-d [WEIGHT]] [--complete] [--purge] [-s] [-v]

Automatically jump to directory passed as an argument.

positional arguments: DIRECTORY directory to jump to

optional arguments: -h, --help show this help message and exit -a DIRECTORY, --add DIRECTORY add path -i [WEIGHT], --increase [WEIGHT] increase current directory weight -d [WEIGHT], --decrease [WEIGHT] decrease current directory weight --complete used for tab completion --purge remove non-existent paths from database -s, --stat show database entries and their key weights -v, --version show version information

Please see autojump(1) man pages for full documentation.

The autojump command needs some adaption to be really useful, even there it ask to change 2 letters in favour of only 1 letter for changing directories on the CLI.