Skip to content

Set your Prompt

It’s a tiny detail, but the default command-line prompt (on both Windows and Unix) drives me nuts.

mswin-command-prompt1

See how my cursor is way over on the right. So every command you ever type gets immediately split over two lines.

This is governed by the PROMPT environment variable. It’s the Windows equivalent of the Unix PS1 variable. You can set this using the environment variable editing GUI on the System Properties dialog. (I’ll describe a better way to manage environment variables in a later post.)

set Prompt=$P$_$G$S

The dollar codes are expanded into:

  • $P – present working directory
  • $_ – newline
  • $G – greater than
  • $S – space

mswin-command-prompt2

There, isn’t that better? There are a bunch of other special dollar codes, that are described here. They only work within this one environment variable, you can’t use them anywhere else.

{ 2 } Comments

  1. Michael Foord | Wed 18 Nov 2009 at 18:54 | Permalink

    Thanks! I can never remember how to do this; basically essential for Windows command line working. :-)

  2. tartley | Wed 18 Nov 2009 at 19:46 | Permalink

    Heh. You’re welcome. I posted this trivia snippet because it was unintimidating enough to get me going again on my ‘Windows development hints and tips’.

{ 1 } Trackback

  1. [...] posts on colored terminal text is perhaps a bit obsessive. I think I'm all done now. Posted by tartley [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *