Last Updated: February 25, 2016
·
1.821K
· adri

Autojump function in the fish shell

Playing with the fish shell I was missing the auto jump function which I was used to from zsh. So I ported the function from bash to fish:

Add the following function to ~/.config/fish/config.fish:

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

Together wish the built in autocomplete in fish this is quite nice.