
| home | AJAX (8) || C#.NET (7) || Coldfusion Development (16) || DHTML (15) || Flash Development (19) || jQuery (8) || MSSQL (2) || UNIX (10) |
| 5.29.08 | Colorized SVN STAT and CVS UPDATE Output Via BASH |
UPDATE –
As per a another post on which I got awk’d - I’d figure if I could take that idea and squeeze it onto a single line instead of using a different awk file. Came up with these:
cvs -q up -dP | awk '{a["A"]=32;a["C"]=31;a["M"]=34;a["U"]=37;a["?"]=36;printf("\033[1;%sm%s\033[0;00m\n",a[$1],$0)}'
… for CVS or for SVN:
svn stat -q | awk '{a["A"]=32;a["C"]=31;a["M"]=34;a["G"]=37;a["D"]=36;printf("\033[1;%sm%s\033[0;00m\n",a[$1],$0)}'
As per a friend’s article,
Color your svn command-line output with svnc!, I thought this would be a great opportunity to show how I’d do it in the BASH shell on a single line of code.
I mostly use CVS above SVN with the repository always residing on a local unix machine. This means I use the command-line for almost all versioning control - for commit, conflict resolution, merging, tagging and release, etc. - which equates to a single line shell command that can colorize the output (assuming you’re on a valid TERM such as TERM=ansi) of the most used UPDATE or STAT versioning command.
Here’s a quick screen of the CVS version’s output:
A src/add.cs
C src/conflict.cs
M src/modified.cs
U src/updated.cs
? src/unknown.cs
Here’s the CVS version (quiet output and PRUNE enabled):
Download this code: color-cvs-update.sh
Here’s the SVN version (quiet output):
Download this code: color-svn-update.sh
This doesn’t include all the specific file-state tags in CVS or SVN, but is a good start. The ANSI color codes are rather obvious as well - so this is open for quick modification. Maybe a PowerShell version could easily be whipped up similar to this.
If you want to alias this in UNIX for all users, setup something in the /etc/bashrc like
alias='/usr/local/bin/cu/.sh'
… and place the following at the top of the /usr/local/bin/cu/.sh file with +x permissions
#!/bin/sh
cvs -q up -dP \
...
No comments