DominicHamon.com
Life is like a grapefruit
Fun with Windows CMD.exe
While I was in a semi-conscious state this morning, my body awaiting the arrival of sweet, sweet caffeine, and due to some issues I’m having with my work environment setup, I happened to check out what environment variables were set. I noticed one named ‘PROMPT’ that I immediately assumed worked similarly to the PS1 and PS2 environment variables under bash.
I briefly searched to see if I could find any documentation on this, but came up short and decided to do my own digging.
The default setting appears to be $P$G, which gives you your current path, followed by the ‘>’ symbol. I went through a heap of $<x> combinations to see what other things I could get into my prompt. Here are the results:
$A &
$B |
$C (
$D Today’s date
$E Some little box character
$F )
$G >
$L <
$N Current path drive letter
$P Current path
$Q =
$S A single space
$T Current time
$V Current version of Windows
$$ $
$& %
$_ Adds a newline
$+<x> x
My new prompt is then
$+[$T$+]$S$P$S$$$S
which looks like:
[ 9:38:26.39] E: $
Now if I can figure out how to get some colour in there, we’re laughing…
On a side note, does tumblr just hate html tables or am I doing something horribly wrong when I try to add them?
Update: If you type ‘prompt /?’ at the command prompt, the above list is laid out for you. That would have saved me some time. If you use the ‘prompt’ command to set your prompt, it seems to only hold for the duration of the cmd process, so it might be useful in a batch file. Perhaps combining this with the ‘color’ command and running that instead of ‘cmd’ directly is the way to get a pretty command prompt.
I’m fairly sure there’s a way to use the $e escape code to get colours too, but no success yet…
Posted on 2008/11/13 in personal | | Leave a comment
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Comment
Name *
Email *
Website
Recent Posts
- London Calling
- The Rise and Fall of Ziggy Stardust
- The only winning move is not to play
- s/GOOG/TWTR/
- URL shortener in go
- All the small things
- gomud
- Hole hearted
- Typed data for performance boost
Archives
- April 2018
- May 2015
- August 2014
- February 2014
- January 2014
- November 2013
- September 2013
- June 2013
- May 2013
- March 2013
- February 2013
- December 2012
- November 2012
- September 2012
- May 2012
- March 2012
- January 2012
- September 2011
- May 2011
- April 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- July 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
Search
Search
Copyright © Dominic Hamon 2021. WordPress theme by Ryan Hellyer.