bash and zsh key bindings for Git objects, powered by fzf
bash and zsh key bindings for Git objects, powered by 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.
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.
# 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|)' "$@"
}
Each binding is backed by _fzf_git_*
function so you can do something like
this in your shell configuration file.
gco() {
_fzf_git_each_ref --no-multi | xargs git checkout
}
gswt() {
cd "$(_fzf_git_worktrees --no-multi)"
}