-
Notifications
You must be signed in to change notification settings - Fork 1
/
git_fuzzy.sh
49 lines (42 loc) · 1.29 KB
/
git_fuzzy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
gf() {
is_in_git_repo &&
git -c color.status=always status --short |
fzf --height 40% -m --ansi --nth 2..,.. | awk '{print $2}'
}
gb() {
is_in_git_repo &&
git branch -vv --color=always --sort=committerdate | grep -v '/HEAD\s' |
fzf --height 40% --ansi --multi --tac | sed 's/^..//' | awk '{print $1}' |
sed 's#^remotes/[^/]*/##'
}
gb_all() {
is_in_git_repo &&
git branch -a -vv --color=always --sort=committerdate | grep -v '/HEAD\s' |
fzf --height 40% --ansi --multi --tac | sed 's/^..//' | awk '{print $1}' |
sed 's#^remotes/[^/]*/##'
}
gt() {
is_in_git_repo &&
git tag --sort -version:refname |
fzf --height 40% --multi
}
gh() {
is_in_git_repo &&
git log --date=short --format="%C(green)%C(bold)%cd %C(auto)%h%d %s (%an)" --graph |
fzf --height 40% --ansi --no-sort --reverse --multi | grep -o '[a-f0-9]\{7,\}'
}
gr() {
is_in_git_repo &&
git remote -v | awk '{print $1 " " $2}' | uniq |
fzf --height 40% --tac | awk '{print $1}'
}
bind '"\er": redraw-current-line'
bind '"\C-g\C-f": "$(gf)\e\C-e\er"'
bind '"\C-g\C-b": "$(gb)\e\C-e\er"'
bind '"\C-g\C-v": "$(gb_all)\e\C-e\er"'
bind '"\C-g\C-t": "$(gt)\e\C-e\er"'
bind '"\C-g\C-h": "$(gh)\e\C-e\er"'
bind '"\C-g\C-r": "$(gr)\e\C-e\er"'