PoshCode Archive  Artifact [ffb86ea541]

Artifact ffb86ea541d34c4a227d1a124d423aa99b9e92fa48f68684d20f6517a53e39a2:

  • File Colorize-Subversion-SVN.ps1 — part of check-in [2ed17c3819] at 2018-06-10 14:26:08 on branch trunk — Colorize Subversion SVN STAT output. (user: jim palmer size: 1113)

# 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
		}
	}
}