Skip to content

Instantly share code, notes, and snippets.

@unicornrainbow
Forked from nas/gbgrep
Created July 6, 2012 18:10
Show Gist options
  • Save unicornrainbow/3061734 to your computer and use it in GitHub Desktop.
Save unicornrainbow/3061734 to your computer and use it in GitHub Desktop.
git blame with grep
#!/usr/bin/env ruby
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}`
files = grep.scan /.*\:\d+/
interrupt = false
files.each do |file_with_line|
exit if interrupt
puts ">>> #{file_with_line}"
file, line = file_with_line.split(':')
system "git blame -L #{line} #{file} | head -n 1"
trap('INT'){interrupt = true}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment