Created
June 27, 2014 13:49
-
-
Save shibayu36/6e88877cf82f7cf75b08 to your computer and use it in GitHub Desktop.
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 peco-git-recent-branches () { | |
local selected_branch=$(git for-each-ref --format='%(refname)' --sort=-committerdate refs/heads | \ | |
perl -pne 's{^refs/heads/}{}' | \ | |
peco) | |
if [ -n "$selected_branch" ]; then | |
BUFFER="git checkout ${selected_branch}" | |
zle accept-line | |
fi | |
zle clear-screen | |
} | |
zle -N peco-git-recent-branches | |
function peco-git-recent-all-branches () { | |
local selected_branch=$(git for-each-ref --format='%(refname)' --sort=-committerdate refs/heads refs/remotes | \ | |
perl -pne 's{^refs/(heads|remotes)/}{}' | \ | |
peco) | |
if [ -n "$selected_branch" ]; then | |
BUFFER="git checkout -t ${selected_branch}" | |
zle accept-line | |
fi | |
zle clear-screen | |
} | |
zle -N peco-git-recent-all-branches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment