PoshCode Archive  Artifact [4908831e11]

Artifact 4908831e11489e15334660ecc57e4e6608f048a846120171de4b73190728256a:

  • File Colorize-Subversion-SVN.ps1 — part of check-in [2f672afdcf] at 2018-06-10 12:56:32 on branch trunk — Colorize Subversion SVN STAT, UPDATE and DIFF (without params) output. (user: Bishop size: 1140)

# encoding: ascii
# api: powershell
# title: Colorize Subversion SVN
# description: Colorize Subversion SVN STAT, UPDATE and DIFF (without params) output.
# version: 0.1
# type: function
# author: Bishop
# license: CC0
# x-poshcode-id: 1143
# x-derived-from-id: 1148
# x-archived: 2009-06-07T13:29:14
#
# Here’s a PowerShell functions that you can use to make those numerous SVN commands you run every day via the PowerShell CLI a little easier to read by adding colors.
#
# draw output
function drawlines($colors, $lines) {
	if (!$lines) { return }
	foreach ($line in $lines) {
		$color = $colors[[string]$line[0]]
		if ($color) {
			write-host $line -Fore $color
		} else {
			write-host $line
		}
	}
}

# svn stat
function ss {
	drawlines @{ "A"="Magenta"; "D"="Red"; "C"="Yellow"; "G"="Blue"; "M"="Cyan"; "U"="Green"; "?"="DarkGray"; "!"="DarkRed" } (svn stat)
}

# svn update
function su {
	drawlines @{ "A"="Magenta"; "D"="Red"; "U"="Green"; "C"="Yellow"; "G"="Blue"; } (svn up)
}

# svn diff
function sd {
	drawlines @{ "@"="Magenta"; "-"="Red"; "+"="Green"; "="="DarkGray"; } (svn diff)
}