mrjohannchang / fz.sh

Cli shell plugin, the missing fuzzy tab completion feature for the z jump around command.
Mozilla Public License 2.0
528 stars 27 forks source link
autocompletion autojump bash bash-completion cd completion fasd fuzzy fuzzy-search j jump oh-my-zsh pluging tab-completion z zplug zsh zsh-completion zsh-plugin

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

gif-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

Fig

Fig adds apps, shortcuts, and autocomplete to your existing terminal.

Install fz in zsh or bash with one click.

Bash

  1. Install fzf via Homebrew.

    brew install fzf
  2. Download 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"
  3. Add the following content to ~/.bashrc:

    if [ -d ~/.bash_completion.d ]; then
      for file in ~/.bash_completion.d/*; do
        . $file
      done
    fi

zsh

  1. Install fzf via Homebrew.

    brew install fzf
  2. Install z and fz via zplug. Add the following content to ~/.zshrc:

    zplug "changyuheng/fz", defer:1
    zplug "rupa/z", use:z.sh

Ubuntu

Bash

  1. Install fzf.

    git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
    ~/.fzf/install
  2. Download 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"
  3. Add the following content to ~/.bashrc:

    if [ -d ~/.bash_completion.d ]; then
      for file in ~/.bash_completion.d/*; do
        . $file
      done
    fi

zsh

  1. Install fzf.

    git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
    ~/.fzf/install
  2. Install 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>

See Also