Skip to content

Instantly share code, notes, and snippets.

@jamesmacaulay
Created September 16, 2008 16:26
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 jamesmacaulay/11053 to your computer and use it in GitHub Desktop.
Save jamesmacaulay/11053 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# branchmate
# opens whichever files you've modified in this git branch compared to master
target = ARGV[0] || 'master'
p (cmd = "git diff #{target} --name-only")
files = `#{cmd}`.split.reject {|f| f =~ /^vendor/}
puts files.join("\n")
if files.length > 10
puts "\nReally open all #{files.length} files? [y/N]"
exit unless $stdin.gets =~ /^[Yy]/
end
`mate .`
files.each {|file| system("mate #{file}")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment