# encoding: ascii
# api: powershell
# title: Colorize Subversion SVN
# description: Colorize Subversion SVN STAT output.
# version: 0.1
# type: function
# author: jim palmer
# license: CC0
# x-poshcode-id: 894
# x-archived: 2009-02-25T08:00:52
#
# 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 by adding colors.
# Modified to remove unnecessary ToString calls (external command calls always yield a list of strings and all of the hash table values are string literals) and to take advantage of the fact that a hash table lookup for a missing key returns $null.
#
## SVN STAT colorizer - http://www.overset.com/2008/11/18/colorized-subversion-svn-stat-powershell-function/
function ss () {
$c = @{ "A"="Magenta"; "D"="Red"; "C"="Yellow"; "G"="Blue"; "M"="Cyan"; "U"="Green"; "?"="DarkGray"; "!"="DarkRed" }
foreach ( $svno in svn stat ) {
$color = $c[$svno.SubString(0,1).ToUpper()]
if ( $color ) {
write-host $svno -Fore $color
} else {
write-host $svno
}
}
}