Skip to content

Instantly share code, notes, and snippets.

@maxjustus
Created November 3, 2023 20:11
Show Gist options
  • Save maxjustus/0120693f528db711c90b073e716162b8 to your computer and use it in GitHub Desktop.
Save maxjustus/0120693f528db711c90b073e716162b8 to your computer and use it in GitHub Desktop.
#!/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