Created
April 20, 2023 18:32
-
-
Save camertron/65d910a0df7eb47ef4f17da97e7e6c2d to your computer and use it in GitHub Desktop.
Interactive branch cleaner
This file contains hidden or 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
# frozen_string_literal: true | |
branches = `git branch`.strip.split("\n").map(&:strip).reject { |b| b.start_with?("*") } | |
branches.each_with_index do |branch, idx| | |
STDOUT.write("[#{idx + 1}/#{branches.size}] Delete '#{branch}' (y/n)? ") | |
answer = gets | |
if answer.strip =~ /[yY]/ | |
system("git branch -D #{branch}") | |
else | |
puts "Leaving '#{branch}' alone" | |
end | |
end | |
puts "Done! Thanks for playing." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment