diff --git a/Examples.md b/Examples.md index 4f6b00b..985eb0e 100644 --- a/Examples.md +++ b/Examples.md @@ -332,6 +332,15 @@ fbr() { 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/[^/]*/##") +} + # fco - checkout git branch/tag fco() { local tags branches target