Displaying SVN Info On Your PowerShell Prompt

by Doug Finke on October 12, 2008

in PowerShell,Subversion,SVN

Came across this post Displaying GIT Branch on your PowerShell prompt and built it for subversion. Add this to your $PROFILE.

function prompt {
 $host.ui.rawui.WindowTitle = $(get-location)
 if(Test-Path .svn) {
  switch -regex (svn st) {
   "^\?" {$other+=1}
   "^A" {$added+=1}
   "^M" {$modified+=1}
   default {}
   $prompt_string = "SVN o:$other a:$added m:$modified >"
  } else {
   $prompt_string = "PS >"
  Write-Host ($prompt_string) -nonewline -foregroundcolor yellow
  return " "

For a directory that is an svn working copy.

  • o:4 – 4 files not under version control
  • a:1 – 1 item scheduled for addition
  • m:1 – 1 item has been modified

Issuing svn add or check in commands causes the prompt to be refreshed.


{ 3 trackbacks }

Episode 46 - SQL PSX « PowerScripting Podcast
10.28.08 at 11:45 pm
Svn and Git enabled Power Shell prompt « Thorsten Lorenz
08.15.10 at 10:05 am
PowerShell Hacker #12
08.21.10 at 6:48 pm

{ 4 comments… read them below or add one }

Hal Rottenberg 10.12.08 at 5:58 pm

Good one, Doug! I’m going to cover this and the Git one on an upcoming podcast (powerscripting.net).

/\/\o\/\/ 10.13.08 at 4:00 pm

Great stuff,

but did you see GIT has PowerTab support now…
.. looks like that would be cool for SVN also ;-)

Greetings /\/\o\/\/

Doug Finke 10.13.08 at 9:42 pm

Is there anything that PowerTab doesn’t support? ;-)

I knew you would be in there.


Per Østergaard 06.04.09 at 8:51 am

Great idea. Enhanced it by defaulting the counters to 0 (as I only have very few files – just started with SVN)

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>