fix completing git branches w/fzf in tmux

Alpha Chen 2 years ago
parent 8efd869899
commit 5f3cf157b8
No known key found for this signature in database

@ -81,6 +81,7 @@ if [ $commands[fzf] ]; then
fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@" fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@"
} }
# files
_gf() { _gf() {
is_in_git_repo || return is_in_git_repo || return
git -c color.status=always status --short | git -c color.status=always status --short |
@ -89,8 +90,8 @@ if [ $commands[fzf] ]; then
cut -c4- | sed 's/.* -> //' cut -c4- | sed 's/.* -> //'
} }
# this B is capitalized so it maybe will work w/tmux? # branches
_gB() { _gg() {
is_in_git_repo || return is_in_git_repo || return
git branch -a --color=always | grep -v '/HEAD\s' | sort | git branch -a --color=always | grep -v '/HEAD\s' | sort |
fzf-down --ansi --multi --tac --preview-window right:70% \ fzf-down --ansi --multi --tac --preview-window right:70% \
@ -99,6 +100,7 @@ if [ $commands[fzf] ]; then
sed 's#^remotes/##' sed 's#^remotes/##'
} }
# tags
_gt() { _gt() {
is_in_git_repo || return is_in_git_repo || return
git tag --sort -version:refname | git tag --sort -version:refname |
@ -106,6 +108,7 @@ if [ $commands[fzf] ]; then
--preview 'git show --color=always {}' --preview 'git show --color=always {}'
} }
# history
_gh() { _gh() {
is_in_git_repo || return is_in_git_repo || return
git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always | git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph --color=always |
@ -115,6 +118,7 @@ if [ $commands[fzf] ]; then
grep -o "[a-f0-9]\{7,\}" grep -o "[a-f0-9]\{7,\}"
} }
# remotes
_gr() { _gr() {
is_in_git_repo || return is_in_git_repo || return
git remote -v | awk '{print $1 "\t" $2}' | uniq | git remote -v | awk '{print $1 "\t" $2}' | uniq |
@ -123,6 +127,7 @@ if [ $commands[fzf] ]; then
cut -d$'\t' -f1 cut -d$'\t' -f1
} }
# stashes
_gs() { _gs() {
is_in_git_repo || return is_in_git_repo || return
git stash list | fzf-down --reverse -d: --preview 'git show --color=always {1}' | git stash list | fzf-down --reverse -d: --preview 'git show --color=always {1}' |
@ -145,7 +150,7 @@ if [ $commands[fzf] ]; then
eval "bindkey '^g^$c' fzf-g$c-widget" eval "bindkey '^g^$c' fzf-g$c-widget"
done done
} }
bind-git-helper f B t r h s bind-git-helper f g t r h s
unset -f bind-git-helper unset -f bind-git-helper
if [ $commands[fasd] ]; then if [ $commands[fasd] ]; then

Loading…
Cancel
Save