PoshCode Logo PowerShell Code Repository

Colorize Subversion SVN by Bishop 32 months ago (modification of post by Bishop view diff)
View followups from Bishop | diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1143"></script>download | new post

Colorize Subversion SVN STAT, UPDATE and DIFF (without params) output.
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.

  1. # draw output
  2. function drawlines($colors, $lines) {
  3.         if (!$lines) { return }
  4.         foreach ($line in $lines) {
  5.                 $color = $colors[[string]$line[0]]
  6.                 if ($color) {
  7.                         write-host $line -Fore $color
  8.                 } else {
  9.                         write-host $line
  10.                 }
  11.         }
  12. }
  13.  
  14. # svn stat
  15. function ss {
  16.         drawlines @{ "A"="Magenta"; "D"="Red"; "C"="Yellow"; "G"="Blue"; "M"="Cyan"; "U"="Green"; "?"="DarkGray"; "!"="DarkRed" } (svn stat)
  17. }
  18.  
  19. # svn update
  20. function su {
  21.         drawlines @{ "A"="Magenta"; "D"="Red"; "U"="Green"; "C"="Yellow"; "G"="Blue"; } (svn up)
  22. }
  23.  
  24. # svn diff
  25. function sd {
  26.         drawlines @{ "@"="Magenta"; "-"="Red"; "+"="Green"; "="="DarkGray"; } (svn diff)
  27. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me