Created
November 3, 2023 20:11
-
-
Save maxjustus/0120693f528db711c90b073e716162b8 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
#!/usr/bin/env ruby | |
require 'bundler/inline' | |
begin | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'tty-prompt', '~> 0.23.1', require: false | |
end | |
rescue => e | |
puts "failed to install gems: #{e}" | |
raise e | |
end | |
require "tty-prompt" | |
count = ARGV[0] || 30 | |
branches = `git branch -v --sort=-committerdate` | |
branches = branches.split("\n").map(&:strip).delete_if { |b| b.start_with?("* ") } | |
prompt = TTY::Prompt.new(interrupt: :exit) | |
branch = prompt.select("Select branch to switch to:", branches).split(" ").first | |
`git checkout #{branch}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment