forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.fzf_aliases
26 lines (24 loc) · 1.02 KB
/
.fzf_aliases
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
export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix'
# # fbr - checkout git branch
# fbr() {
# local branches branch
# branches=$(git --no-pager branch -vv) &&
# branch=$(echo "$branches" | fzf +m) &&
# git checkout $(echo "$branch" | awk '{print $1}' | sed "s/.* //")
# }
# # fbr - checkout git branch (including remote branches)
# fbr() {
# local branches branch
# branches=$(git branch --all | grep -v HEAD) &&
# branch=$(echo "$branches" |
# fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
# git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
# }
# fbr - checkout git branch (including remote branches), sorted by most recent commit, limit 30 last branches
fbr() {
local branches branch
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
branch=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}