Skip to content

Instantly share code, notes, and snippets.

@theirix
Created October 17, 2014 14:59
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 theirix/7034971c3c11dcfbde01 to your computer and use it in GitHub Desktop.
Save theirix/7034971c3c11dcfbde01 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Classify homebrew formulas by origins
def repo f
STDERR.print '.'
`brew info #{f}`.split("\n").map(&:chomp).each do |s|
if s =~ /^From: (.*)/
return $1.gsub(/^https:\/\/github.com\/(.*)\/blob\/.*/, '\1')
end
end
return nil
end
puts 'Determine formula origins...'
`brew list`.split("\n").map(&:chomp).map { |f| [f, repo(f)] }.group_by { |f,r| r }.each do |r,fa|
puts "\n#{r ? r : 'none'}"
fa.each{|f,_| puts "\t"+f }
end
# vim: ft=ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment