Skip to content

Instantly share code, notes, and snippets.

@rsky
Created May 13, 2011 06:04
Show Gist options
  • Save rsky/970064 to your computer and use it in GitHub Desktop.
Save rsky/970064 to your computer and use it in GitHub Desktop.
~/.subversion/config の diff-cmd に指定して Git の [color] ui=auto 風に
#!/usr/bin/env python
import sys, subprocess
class AutoColorDiff:
diff = 'diff'
colordiff = 'colordiff'
def run(self, args,
stdin = None, stdout = None, stderr = None,
close_fds = True):
diff_cmd = self.diff
if stdout == None:
stdout = sys.stdout
if hasattr(stdout, 'isatty') and stdout.isatty():
diff_cmd = self.colordiff
args.insert(0, diff_cmd)
return subprocess.Popen(args,
stdin = stdin, stdout = stdout, stderr = stderr,
close_fds = close_fds).wait()
if __name__ == '__main__':
exit(AutoColorDiff().run(sys.argv[1:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment