Return to Snippet

Revision: 14195
at May 22, 2009 22:29 by phalkunz


Initial Code
#!/usr/bin/python
"""
 Author: Saophalkun Ponlu (http://phalkunz.com)
 Contact: [email protected]
 Date: May 23, 2009
"""

import sys, os, re

# add more status & color codes 
colors = {
	"M": "31",		# red 
	"\?": "32", 	# green
	"C": "30;41"	# black on red
}

# build a paramter list
parameters = "";
for i in range(1, sys.argv.__len__()):
	parameters += sys.argv[i] + " ";

status = os.popen('svn st ' + parameters);
for line in status:
	passed = False
	# remove newline character from the line
	line = re.sub("\n", "", line)
	
	for color in colors:
		match = re.match(color+(" "*6), line)
		if match:	
			os.popen("echo '\E[" + colors[color] + "m" + line + "\E[m'", 'w')
			passed = True
	if(passed):
		continue
		
	os.popen("echo \"" + line + "\"", 'w')

Initial URL
http://phalkunz.com/2009/05/23/print-color-coded-svn-status/

Initial Description

                                

Initial Title
Color coded SVN status

Initial Tags
svn, Bash, python

Initial Language
Python