forgit: Interactive Git Commands With Previews Powered By fzf Fuzzy Finder
forgit is a command line utility that takes advantage of the popular fzf fuzzy finder to provide interactive git commands, with previews.
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
forgit provides the following commands:
Here's a screenshot of the the git add command (
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
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
You might like: z.lua - A Faster Way Of Changing Directories (cd Command That Learns As You Use It)
These are the default forgit key bindings:
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
Since we've cloned the forgit git repository, we can easily update it later with a simple
2. Next you'll need to source
Open
The forgit plugin is identical for both Zsh and Bash, that's why even though the file extension is
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
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.
Interactive git log (glo when using forgit) viewer with file previews for the command line, using forgit (powered by fzf) |
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:
ga
: interactivegit add
selectorglo
: interactivegit log
viewergi
: interactive.gitignore
generatorgd
: interactivegit diff
viewergrh
: interactive interactivegit reset HEAD <file>
selectorgcf
: interactivegit checkout <file>
selectorgss
: interactivegit stash
viewergclean
: interactivegit clean
selector
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
~/.bashrc
or ~/.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 git log
.You might like: z.lua - A Faster Way Of Changing Directories (cd Command That Learns As You Use It)
These are the default forgit key bindings:
Enter
: confirmTab
: toggle mark?
: toggle preview windowAlt - W
: toggle preview wrapCtrl - S
: toggle sortCtrl - R
: toggle selectionCtrl - K / P
: selection move upCtrl - J / N
: selection move downAlt - K / P
: preview move upAlt - J / N
: preview move down
Installation
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 ~/.forgit
directory.2. Next you'll need to source
~/.forgit/forgit.plugin.zsh
in your shell config.Open
~/.bashrc
or ~/.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:
- Bash:
source ~/.bashrc
- Zsh
source ~/.zshrc
You might also find this interesting: Starship Is A Minimal And Fast Shell Prompt Written In Rust