Skip to content

Instantly share code, notes, and snippets.

@jbodah
Created February 4, 2019 15:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jbodah/de5473018ced3c4d2f3f277b2e86c610 to your computer and use it in GitHub Desktop.
Save jbodah/de5473018ced3c4d2f3f277b2e86c610 to your computer and use it in GitHub Desktop.
git-cc
#! /usr/bin/env ruby
require 'tty/prompt'
require 'tty/prompt/vim'
prompt = TTY::Prompt.new
branches = `git for-each-ref --sort=-committerdate --count=20 --format='%(refname:short)' refs/heads/`.each_line.map(&:rstrip)
branch = prompt.select("Choose a branch:", branches)
exec "git checkout #{branch}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment