Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junegunn/fzf-git.sh
bash and zsh key bindings for Git objects, powered by fzf
https://github.com/junegunn/fzf-git.sh
bash fzf zsh
Last synced: about 2 months ago
JSON representation
bash and zsh key bindings for Git objects, powered by fzf
- Host: GitHub
- URL: https://github.com/junegunn/fzf-git.sh
- Owner: junegunn
- Created: 2022-08-14T14:35:54.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-07T09:45:13.000Z (3 months ago)
- Last Synced: 2024-06-07T11:08:55.663Z (3 months ago)
- Topics: bash, fzf, zsh
- Language: Shell
- Homepage:
- Size: 52.7 KB
- Stars: 469
- Watchers: 12
- Forks: 38
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
fzf-git.sh
==========bash and zsh key bindings for Git objects, powered by [fzf][fzf].
Each binding will allow you to browse through Git objects of a certain type,
and select the objects you want to paste to your command-line.[fzf]: https://github.com/junegunn/fzf
[fzf-tmux]: https://github.com/junegunn/fzf/blob/master/bin/fzf-tmuxInstallation
------------1. Install the latest version of [fzf][fzf] (including [fzf-tmux][fzf-tmux])
* (Optional) Install [bat](https://github.com/sharkdp/bat) for
syntax-highlighted file previews
1. Source [fzf-git.sh](https://raw.githubusercontent.com/junegunn/fzf-git.sh/main/fzf-git.sh) file from your .bashrc or .zshrcUsage
-----### List of bindings
* CTRL-GCTRL-F for **F**iles
* CTRL-GCTRL-B for **B**ranches
* CTRL-GCTRL-T for **T**ags
* CTRL-GCTRL-R for **R**emotes
* CTRL-GCTRL-H for commit **H**ashes
* CTRL-GCTRL-S for **S**tashes
* CTRL-GCTRL-L for ref**l**ogs
* CTRL-GCTRL-W for **W**orktrees
* CTRL-GCTRL-E for **E**ach ref (`git for-each-ref`)> [!WARNING]
> You may have issues with these bindings in the following cases:
>
> * CTRL-GCTRL-B will not work if
> CTRL-B is used as the tmux prefix
> * CTRL-GCTRL-S will not work if flow control is enabled,
> CTRL-S will freeze the terminal instead
> * (`stty -ixon` will disable it)
>
> To workaround the problems, you can use
> CTRL-G*{key}* instead of
> CTRL-GCTRL-*{KEY}*.
>> [!WARNING]
> If zsh's `KEYTIMEOUT` is too small (e.g. 1), you may not be able
> to hit two keys in time.### Inside fzf
* TAB or SHIFT-TAB to select multiple objects
* CTRL-/ to change preview window layout
* CTRL-O to open the object in the web browser (in GitHub URL scheme)Customization
-------------```sh
# Redefine this function to change the options
_fzf_git_fzf() {
fzf-tmux -p80%,60% -- \
--layout=reverse --multi --height=50% --min-height=20 --border \
--border-label-pos=2 \
--color='header:italic:underline,label:blue' \
--preview-window='right,50%,border-left' \
--bind='ctrl-/:change-preview-window(down,50%,border-top|hidden|)' "$@"
}
```Defining shortcut commands
--------------------------Each binding is backed by `_fzf_git_*` function so you can do something like
this in your shell configuration file.```sh
gco() {
_fzf_git_each_ref --no-multi | xargs git checkout
}gswt() {
cd "$(_fzf_git_worktrees --no-multi)"
}
```Environment Variables
---------------------| Variable | Description | Default |
| ----------------------- | -------------------------------------------------------- | ----------------------------------------------- |
| `BAT_STYLE` | Specifies the style for displaying files using `bat` | `full` |
| `FZF_GIT_CAT` | Defines the preview command used for displaying the file | `bat --style=$BAT_STYLE --color=$FZF_GIT_COLOR` |
| `FZF_GIT_COLOR` | Set to `never` to suppress colors in the list | `always` |
| `FZF_GIT_PAGER` | Specifies the pager command for the preview window | `$(git config --get core.pager)` |
| `FZF_GIT_PREVIEW_COLOR` | Set to `never` to suppress colors in the preview window | `always` |