A bash function that patches the native cd to allow changing directories
instantly using a fuzzy match, with or without an interactive menu.
- Preserves the native
cdcompletion. - Understands
CDPATH. - Remembers all visited directories.
- Allows changing directory to any directory from the history that matches the input fuzzy search (unless it matches an actual directory).
- Shows available choices with
lspreview, when there are more than one matches (optional). - Does not override the builtin
cdwhen running non-interactively. - Adds flags such as
cd -lto view and manage the history. - Three operation modes:
- Minimal - cd to best match
- Interactive
- Interactive with
lspreview
- Optional bash completions that prefer native
cdmatches before fuzzy history.
Fuzzy CD requires a recent version of fzf.
Use the setup script for automatic installation. It installs
fuzzycd and adds the required shell startup hook.
$ curl -Ls get.dannyb.co/fuzzycd/setup | bash- Place the
fuzzycdfile somewhere on yourPATHand make it executable. - Source it from your startup script (for example:
source /usr/local/bin/fuzzycdin~/.bashrc).
Show Usage Patterns
$ cd -h
Usage:
cd DIR change working directory
cd SEARCH change working directory or show selection menu
cd -l list history with fzf
cd -e edit history file
cd -s show history file
cd -p prune non-existent directories from history
cd -d [DIR] delete current or specified directory from history
cd -c show completions function [usage: eval "$(cd -c)"]
cd -v show version
cd -h show this help
Environment Variables:
FUZZYCD_HISTORY_FILE
Path to history file (default: ~/.fuzzycd-history)
FUZZYCD_MODE
Set operation mode (one of: m, i, p)
m = minimal, non interactive, always cd to best match (default)
i = interactive when needed, no preview
p = interactive when needed, with ls preview
FUZZYCD_COMPLETIONS_COUNT
Maximum number of suggestions to show in bash completions
(default: 10)
Interactive Keyboard Bindings:
Del
Delete selected directory from history
First, verify that Fuzzy CD is properly installed by running:
$ cd -hNow, you can use cd normally to change to any directory. These directories
will be remembered in a history file. You can view this file by running:
$ cd -s
# or
$ cat ~/.fuzzycd-historyUse cd with a string that is not a directory. If exactly one directory in
the history matches this string, you will instantly cd to it as usual.
If more than one directories match, you will be prompted to choose one of the
matching directories when running in interactive mode, or you will
cd to the best match when running in non-interactive mode (default).
If you install using the setup script, fuzzy bash completions are
enabled automatically for Bash.
If you install manually, add the following line to your ~/.bashrc:
eval "$(fuzzycd -c)"These completions keep Bash's native cd matches first and then append fuzzy
history matches without duplicates.
This works best when tab completion is configured for inline completions, which
you can set by adding/updating the ~/.inputrc file:
# ~/.inputrc
TAB: menu-completeUse the uninstall script for automatic removal:
$ curl -Ls get.dannyb.co/fuzzycd/uninstall | bashOr remove it manually:
- Remove the line that sources
fuzzycdfrom your startup script. - Remove the
eval "$(fuzzycd -c)"line from your startup script, if you added it manually. - Delete the
fuzzycdexecutable from yourPATH. - Optionally, delete the history file (
~/.fuzzycd-history). - Restart your session.
If you experience any issue, have a question or a suggestion, or if you wish to contribute, feel free to open an issue.
Tests are split into two layers:
test/approvekeeps exact-output approval coverage and low-level shell assertions.features/contains Shellkin acceptance scenarios for the main user-facing flows.
Run them with op test, or run the acceptance layer alone with op acceptance.
| This repository is part of the Bash Productivity Suite | |||
![]() |
![]() |
![]() |
![]() |




