Welcome to MSDN Blogs Sign in | Join | Help

Setting the console title to be your current working directory

jmanning wrote:

Also, given how common the request is, I'd ask Jeffrey to (pretty-please) also include in this post a prompt function that sets the title to include pwd.

Ask and yea shall receive:

function Prompt
{
  $host.ui.RawUI.WindowTitle = $(get-location)
  "PS> "
}

If you want to see a bunch of great prompt examples, check out:

http://mshforfun.blogspot.com/2006/05/perfect-prompt-for-windows-powershell.html

Jeffrey Snover [MSFT]
Windows PowerShell/Aspen Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

 

PSMDTAG:FAQ:  How do I set the Console Title to my current working directory?

PSMDTAG:SHELL: Prompt

PSMDTAG:ENVIRONMENT: Prompt

Published Friday, July 21, 2006 8:51 AM by PowerShellTeam

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Customizing Windows Powershell « shortcircuited

Tuesday, October 24, 2006 5:33 PM by Customizing Windows Powershell « shortcircuited

# re: Setting the console title to be your current working directory

I understand what the function is doing but I dont understand why when I put it in my profile the function executes automatically?  Is "prompt" called automatically by MSH?

Secondly, how does "PS >" set the prompt?  

Thank you,

Fred Jacobowitz

Saturday, October 28, 2006 1:07 PM by Fred Jacobowitz

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker