fz
A shell plugin that seamlessly adds fuzzy search to tab completion of z, lets you easy to jump around among your historical directories. Not any additional key binding is needed. Currently supports Bash and zsh.
Demo

Installation
By simply sourcing corresponding script file for your shell, you're all set. However, this plugin is sitting on top of z and fzf, so you must have them installed as well.
N.B. fz needs to be sourced after z.
macOS
Bash
Install fzf via Homebrew.
brew install fzfDownload z and fz.
mkdir ~/.bash_completion.d curl "https://raw.githubusercontent.com/rupa/z/master/{z.sh}" \ -o ~/.bash_completion.d/"#1" curl "https://raw.githubusercontent.com/changyuheng/fz/master/{fz.sh}" \ -o ~/.bash_completion.d/z"#1"Add the following content to
~/.bashrc:if [ -d ~/.bash_completion.d ]; then for file in ~/.bash_completion.d/*; do . $file done fi
zsh
Install fzf via Homebrew.
brew install fzfInstall z and fz via zplug. Add the following content to
~/.zshrc:zplug "changyuheng/fz", defer:1 zplug "rupa/z", use:z.sh
Ubuntu
Bash
Install fzf.
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf ~/.fzf/installDownload z and fz.
mkdir ~/.bash_completion.d curl "https://raw.githubusercontent.com/rupa/z/master/{z.sh}" \ -o ~/.bash_completion.d/"#1" curl "https://raw.githubusercontent.com/changyuheng/fz/master/{fz.sh}" \ -o ~/.bash_completion.d/z"#1"Add the following content to
~/.bashrc:if [ -d ~/.bash_completion.d ]; then for file in ~/.bash_completion.d/*; do . $file done fi
zsh
Install fzf.
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf ~/.fzf/installInstall z and fz via zplug. Add the following content to
~/.zshrc:zplug "changyuheng/fz", defer:1 zplug "rupa/z", use:z.sh
Usage
z [dir name slug]<TAB>
zz [dir name slug]<TAB>
- The function of fz is pretty much like what it is of
z.
zzlimits the search base starting from current working directory. Check z’s doc for more information. tab/shift-tab,ctrl-n/ctrl-p,ctrl-j/ctrl-k, for next and previous item.Enterfor selection. Check fzf’s doc for the search syntaxes.FZ_CMD=zspecifies command name offz. Default isz.FZ_SUBDIR_CMD=zzspecifies command name for subdirectory onlyz. Default iszz.FZ_SUBDIR_TRAVERSAL=0disables subdirectory completion. Default is enabled.FZ_CASE_INSENSITIVE=0disables case-insensitive subdirectory completion. Default is enabled.FZ_ABBREVIATE_HOME=0disables abbreviating~. Default is enabled.FZ_HISTORY_CD_CMD=_zluaworks with z.lua.
See Also
- cdr + zaw
- fzf’s readme of completion and its wiki
- fasd
- autojump
- z.lua
- 命令行上的narrowing(随着输入逐步减少备选项)工具