Last active
September 21, 2018 15:26
-
-
Save dohq/8a1c63c104917d3ad1ffd879854826ca to your computer and use it in GitHub Desktop.
peco-branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#bindkey '^B' select branch for Peco | |
function peco-branch () { | |
local branch=$(git branch -a | peco | tr -d ' ' | tr -d '*') | |
if [ -n "$branch" ]; then | |
if [ -n "$LBUFFER" ]; then | |
local new_left="${LBUFFER%\ } $branch" | |
else | |
local new_left="$branch" | |
fi | |
BUFFER=${new_left}${RBUFFER} | |
CURSOR=${#new_left} | |
fi | |
} | |
zle -N peco-branch | |
bindkey '^b' peco-branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment