Last active
July 27, 2019 10:12
-
-
Save dohq/7cb290f0a9a90e8f24f0f4912f6633b8 to your computer and use it in GitHub Desktop.
fzf-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
function fzf-branch() { | |
local selected_branch=$(git for-each-ref --format='%(refname)' --sort=-committerdate refs/heads | perl -pne 's{^refs/heads/}{}' | fzf --query "$LBUFFER" --prompt="Git Branch > ") | |
if [ -n "$selected_branch" ]; then | |
BUFFER="git checkout ${selected_branch}" | |
zle accept-line | |
fi | |
zle reset-prompt | |
} | |
zle -N fzf-branch | |
bindkey "^b" fzf-branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment