Skip to content

Instantly share code, notes, and snippets.

@morishin
Created August 24, 2016 16:02
Show Gist options
  • Save morishin/5983269d1384a4f5773dc4265d7f9132 to your computer and use it in GitHub Desktop.
Save morishin/5983269d1384a4f5773dc4265d7f9132 to your computer and use it in GitHub Desktop.
function peco-select-git-checkout() {
local selected_branch="$(git branch --sort=-committerdate | grep -v '^\*.*' | peco --query "$LBUFFER" | awk -F ' ' '{print $1}')"
if [ -n $selected_branch ]; then
BUFFER="git checkout $selected_branch"
CURSOR=$#BUFFER
zle accept-line
fi
}
zle -N peco-select-git-checkout
bindkey "^gc" peco-select-git-checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment