Skip to content

Instantly share code, notes, and snippets.

@iorionda
Last active November 10, 2015 09:57
Show Gist options
  • Save iorionda/eada55abe662fe5d4f38 to your computer and use it in GitHub Desktop.
Save iorionda/eada55abe662fe5d4f38 to your computer and use it in GitHub Desktop.
function peco-select-git-branch
set -l query (commandline)
if [ (count $query) = 0 ]
set peco_flag --layout=bottom-up
else
set peco_flag --layout=bottom-up --query "$query"
end
git rev-parse --git-dir >/dev/null 2>&1
if [ "$status" = "0" ]
git branch | grep -v "*" | tail -r | awk '{ print $1 }' | peco $peco_flag | read line
else
return 1
end
if [ $line ]
git checkout $line
else
commandline -f repaint
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment