Guest User

git branch menu using fzf (zsh syntax)

a guest
Apr 25th, 2020
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.44 KB | None | 0 0
  1. fbr () {
  2.     local branches branch
  3.     local query=$1
  4.     local opts="--cycle +m -e --color=spinner:233,info:233 --select-1 --exit-0 --preview-window down:10 --height 50%"
  5.     if ! [[ -z "${query// }" ]]
  6.     then
  7.         opts="$=opts -q ${query}"
  8.     fi
  9.     branches=$(git branch)  && branch=$(echo "$branches" | fzf "$=opts" --preview 'git --no-pager log --oneline --decorate --graph -n10 {1}')  && git checkout $(echo "$branch" | awk '{print $1}' | sed "s/.* //")
  10. }
Advertisement
Add Comment
Please, Sign In to add comment