Skip to content
llagerlofPublic

About

On Linux, use the `cd` command to jump to any previously visited directory typing `cd part_of_path`, anywhere.

Resources

Stars

13 stars

Watchers

1 watching

Forks

Latest commit

 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Autoleap

Jump to any previously visited directory by typing only part of its path.

How to use it

After using the cd command several times, you'll have a collection of previously visited directories that you can access like bookmarks.

For example, suppose you once visited /home/user/Downloads/. The next time you want to return to the Downloads directory, you can simply type cd Downloads from anywhere, or even cd Dow.

demonstration

How it works

The script declares a cd function that wraps your shell's own cd command. Every time you change directories, the full path is stored in ~/.autoleap.history.

Your shell's own cd is always attempted first, so all standard behavior is fully preserved — in Bash that includes CDPATH, cd -, cd old new substitution, and options such as -P and -L; in Fish it includes CDPATH, cd -, and the prevd/nextd/cdh directory history.

Autoleap only activates as a fallback when your shell's cd cannot resolve the path.

When the fallback is triggered, Autoleap searches the history file using your input and changes to the best matching directory. If multiple matches are found, Autoleap uses fzf (if available) to display an interactive selection menu. Exact matches on the final directory name are prioritized over broader substring matches, while preserving that ranking in the displayed list.

Directories that no longer exist are automatically removed from the history file when encountered.

Both shells share the same history file and the same matching code: autoleap.sh holds the entire matching implementation, and the Fish integration calls it as a command to ask "which directory best matches this?", then performs the cd itself. Bash and Fish sessions therefore build one common set of bookmarks.

Installation

Requirements

  • Bash: Fish users need it too: autoleap.sh provides the directory matching for both shells, so it must be installed even if you never use Bash interactively.
  • fzf (optional). Install the package for your Linux distribution to enable the interactive directory selection menu.

Bash

  • Download autoleap.sh to a convenient location (for example, ~/.local/bin/).
  • Source the script from your .bashrc by adding the following line:
source ~/.local/bin/autoleap.sh
  • Restart your terminal or run:
source ~/.bashrc

Fish

  • Download both autoleap.sh and autoleap.fish to the same location (for example, ~/.local/bin/ or /usr/local/bin/).
  • Source the Fish file from your config.fish by adding the following line, adjusting the path to wherever you saved it:
source ~/.local/bin/autoleap.fish
  • Restart your terminal or run:
source ~/.config/fish/config.fish

autoleap.fish locates autoleap.sh on its own: first beside itself (following symlinks, so linking autoleap.fish into conf.d/ works), then in ~/.local/bin/, /usr/local/bin/ and /usr/bin/. Keeping the two files together is all that is normally required.

Only if you keep them in separate directories, set $autoleap_script to the full path of autoleap.sh before sourcing:

set -g autoleap_script /path/to/autoleap.sh
source /somewhere/else/autoleap.fish

Acknowledgments

This project was inspired by wting/autojump. However, autojump is larger than I wanted and has too many dependencies, so I created autoleap.

About

On Linux, use the `cd` command to jump to any previously visited directory typing `cd part_of_path`, anywhere.

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages