Created
May 20, 2011 18:19
-
-
Save nas/983471 to your computer and use it in GitHub Desktop.
git blame with grep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}` | |
puts "\n-----------------------------------------------------------" | |
puts "GREP RESULT" | |
puts '-----------------------------------------------------------' | |
puts grep | |
files = grep.scan /.*\:\d+/ | |
interrupt = false | |
files.each do |file_with_line| | |
exit if interrupt | |
puts "\n-----------------------------------------------------------" | |
puts file_with_line | |
puts '-----------------------------------------------------------' | |
file, line = file_with_line.split(':') | |
system "git blame -L #{line} #{file}" | |
trap('INT'){interrupt = true} | |
sleep 0.4 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment