CURRENT PROJECTS
loading
CATEGORIES AND POSTS
loading
overset
DEVELOPMENT LOG FOR JIM PALMER
Posted 11/18/2008 in powershell


Hot on the heels of my previous post, Colorized SVN STAT and CVS UPDATE Output Via BASH, Here's a PowerShell function that you can use to make those numerous SVN STAT commands you run every day via the PowerShell CLI a little easier to read.

Here's a screenshot of PowerShell wrapped in Console2 running the ss and su function (svn stat and svn up):


This requires the Subversion CLI windows binary installed and accessible in your PATH - get it at http://subversion.tigris.org/

Here's the code for the svn stat function:
function ss () {
	$c = @{ "A"="Magenta"; "D"="Red"; "C"="Yellow"; "G"="Blue"; "M"="Cyan"; "U"="Green"; "?"="DarkGray"; "!"="DarkRed" }
	foreach ( $svno in svn stat ) {  
		if ( $c.ContainsKey($svno.ToString().SubString(0,1).ToUpper()) ) { 
			write-host $svno -Fore $c.Get_Item($svno.ToString().SubString(0,1).ToUpper()).ToString()
		} else { 
			write-host $svno
		}
	}
}
Download: svn.stat.color.function

Here's the code for the svn up function:
function su () {
        $c = @{ "A"="Magenta"; "D"="Red"; "U"="Green"; "C"="Yellow"; "G"="Blue"; }
        foreach ( $svno in svn up ) {  
                if ( $c.ContainsKey($svno.ToString().SubString(0,1).ToUpper()) ) {
                        write-host $svno -Fore $c.Get_Item($svno.ToString().SubString(0,1).ToUpper()).ToString()
                } else {
                        write-host $svno
                }
        }
}
Download: svn.up.color.function

To add this as a permanent function to use, similar to a bash alias, just add this function to your $Profile file. Load up a PowerShell and
notepad $Profile
, add the function, save the file, done.

Note that this is not a signed script - and if you're default PowerShell install still runs under Restricted ExecutionPolicy - the profile will not be loaded.

Check your excution policy via the
get-executionpolicy
command. I run in unrestricted mode via the
set-executionpolicy unrestricted
command.
comments
loading
new comment
NAME
EMAIL ME ON UPDATES
EMAIL (hidden)
URL
MESSAGE TAGS ALLOWED: <code> <a> <pre class="code [tab4|tabX|inline|bash]"> <br>
PREVIEW COMMENT
TURING TEST
gravatar