New to fzf? This is a command line fuzzy finder that can be used for a wide range of purposes. This interactive command line filter can be used with various lists, like files, command history, processes, hostnames, git commits, and more.
fzf is very fast, it’s portable with no dependencies (it’s written in Go), it has a flexible layout, and includes various extra features like the ability to preview highlighted files in a split window inside fzf (which is what forgit uses for its previewing files), a Vim/Neovim plugin, a script for launching fzf in a tmux pane, key bindings and fuzzy auto-completion.
forgit is a shell script for Bash, Zsh and Fish that takes advantage of fzf to make git commands interactive, with instant previews. git already has an
-i/--interactive option, but forgit is more intuitive, makes uses of fzf’s fast fuzzy search, and comes with extras like Vim key bindings.
forgit provides the following commands:
grh: interactive interactive
git reset HEADselector
Here’s a screenshot of the the git add command (
ga) provided by forgit:
The commands provided by forgit are aliases that can be easily change if you wish, by defining them before sourcing forgit (e.g. in your
~/.zshrc file) if you’re not using a plugin manager. You may also add default fzf options to forgit so you can change the keybinds or layout. Check out the forgit documentation for more information.
forgit also includes out of the box integration with some third party command line tools that provide various enhancements. Install diff-so-fancy (make your diffs human readable to help improve code quality and help you spot defects faster) or delta (a syntax-highlighting pager for git) to improve the
git diff output, bat (cat with syntax highlighting) to provide syntax highlighting for gitignore, and emoji-cli for supporting emoji in
These are the default forgit key bindings:
Tab: toggle mark
?: toggle preview window
Alt - W: toggle preview wrap
Ctrl - S: toggle sort
Ctrl - R: toggle selection
Ctrl - K / P: selection move up
Ctrl - J / N: selection move down
Alt - K / P: preview move up
Alt - J / N: preview move down
To use forgit you’ll need to install fzf first. fzf is available in the repositories for Fedora, openSUSE Tumbleweed, Debian Buster, Ubuntu 19.04 and newer, and Arch Linux. You may also download the fzf binary and install it somewhere in your path (like /usr/local/bin), use an install script or Homebrew/Linuxbrew. See the instructions from the fzf wiki for details on installing fzf, and all the available options.
Once fzf is installed you can install forgit using a a ZSH Plugin manager, or manually, by cloning its Git repository and sourcing it in your shell config. You can install it manually follows:
1. Clone the forgit repository in a hidden
~/.forgit folder (you’ll obviously need to have git installed on your system for this):
git clone https://github.com/wfxr/forgit ~/.forgit
Since we’ve cloned the forgit git repository, we can easily update it later with a simple
git pull in the
2. Next you’ll need to source
~/.forgit/forgit.plugin.zsh in your shell config.
~/.zshrc (depending on what you’re using) with a text editor and at the end of it (after sourcing fzf!), add the following:
[ -f ~/.forgit/forgit.plugin.zsh ] && source ~/.forgit/forgit.plugin.zsh
The forgit plugin is identical for both Zsh and Bash, that’s why even though the file extension is
.zsh, it works on both Zsh and Bash.
3. Restart your shell or reload config file
To reload your config file you can use:
You might also find this interesting: Starship Is A Minimal And Fast Shell Prompt Written In Rust