Skip to content

Instantly share code, notes, and snippets.

@reneweteling
Created July 6, 2018 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reneweteling/4524e2500a69755c170feeca6b1221b1 to your computer and use it in GitHub Desktop.
Save reneweteling/4524e2500a69755c170feeca6b1221b1 to your computer and use it in GitHub Desktop.
Little command to print all git branches of all folders in specified location
#!/usr/bin/env ruby
# Author: René Weteling
# Email: rene@weteling.com
# Description: Command to list all branches of all folders at a specified
# locaton. Handy if you have multiple projects.
# Installation:
# 1 - Store in your path (usually ~/bin/gitbranches)
# 2 - Make executable (chmod +x gitbranches)
# 3 - Source your terminal, and enjoy (gitbranches [path || '.'])
path = ARGV[0] || '.'
path = "#{Dir.pwd}/#{path}" unless path[0] == '/'
def print_git_branches(dir)
puts "\033[0;42;30m#{dir}\033[0m"
puts `cd #{dir} && git branch --list`
end
Dir
.glob("#{path}/*")
.select { |f| File.directory? f }
.each{|f| print_git_branches f }
@reneweteling
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment