Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active June 5, 2019 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chmouel/ecb59b7d265a7f14997b9ad74515edcb to your computer and use it in GitHub Desktop.
Save chmouel/ecb59b7d265a7f14997b9ad74515edcb to your computer and use it in GitHub Desktop.
Choose branch with FZF including preview diff with bat
chosen=$(git branch --sort=-committerdate --format '%(refname:short)' -l|grep -v heads/|fzf --border --preview "git log --no-merges --patch-with-stat {}|bat --language=diff --color=always" --bind CTRL-P:preview-up,CTRL-N:preview-down,CTRL-SPACE:preview-page-down --preview-window=up:80%)
[[ $1 == -n ]] && { echo $chosen ; return ;}
git checkout ${chosen}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment