Autojump is a tool that can be used to jump around in the shell to frequently used directories by typing just a part of their name. It is typically aliased to j
. Autojump is available as a package in the Ubuntu repositories, but it needs manual intervention to be available in the fish shell.
1. Install autojump
sudo apt install autojump
2. Source the autojump.fish file in your fish configuration, by opening the file ~/.config/fish/config.fish
in an editor and adding these lines:
begin
set --local AUTOJUMP_PATH /usr/share/autojump/autojump.fish
if test -e $AUTOJUMP_PATH
source $AUTOJUMP_PATH
end
end
3. Add j
shortcut command to fish creating a new file ~/.config/fish/functions/j.fish
with the following content:
function j
set new_path (autojump $argv)
if test -d "$new_path"
echo $new_path
cd "$new_path"
else
echo "autojump: directory '$argv' not found"
echo "Try \`autojump --help\` for more information."
false
end
end
Usage examples:
– j Down
– changes to my Downloads folder
– j work
– changes to my workspace folder
Enjoy!