Last active
June 22, 2018 05:04
-
-
Save ndyakov/a553f0c58d55adc3c442f73027a412a0 to your computer and use it in GitHub Desktop.
[fish] Remove local git branches that are not in origin.
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 gitclb --description 'Remove local branches that are not in origin' | |
git fetch -p | |
set default N | |
set options "y/N" | |
for option in $argv | |
switch "$option" | |
case "-Y" "--yes" | |
set default Y | |
set options "Y/n" | |
end | |
end | |
# get - https://github.com/fisherman/get | |
for branch in (git branch -vv | awk '{print $1,$4}' | grep 'gone]' | awk '{print $1}') | |
get --prompt="Remove $branch [$options]? " --rule=[yYnN] --default="$default" | read confirm | |
switch $confirm | |
case y Y | |
git branch -D $branch | |
end | |
end | |
for branch in (git branch -vv | cut -c 3- | awk '$3 !~/\[/ { print $1 }') | |
get --prompt="Remove local branch $branch [$options]? " --rule=[yYnN] --default="$default" | read confirm | |
switch $confirm | |
case y Y | |
git branch -D $branch | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment