Windows Tip Sheet
ANSI About Your Command Prompt?
A new-generation command prompt for those who remember the good ol' days of ANSI.
- By Jeffery Hicks
In my quest for the perfect command prompt, I’ve resurrected ANSI. For my more mature readers, this might bring back fond memories. The Ansi.sys driver allowed you to add special formatting and colors to your DOS prompt. You can still use the Ansi.sys driver in a Command.com prompt in Windows XP, but since the prompt itself is of limited power, why bother?
However, you can download a replacement ANSI program that will work with the CMD prompt. Go to http://www.robvanderwoude.com/ansi.html and follow the download link for Ansi.com. There’s no install; just put the file in your Windows or System32 folder and you’re set.
Once downloaded, open a CMD prompt and type: ansi.com.
You’ll need to hit enter a few times or type CLS to clear the screen. Now for the magic. Type:
When you press the Enter key, you should have a green prompt. Try this to change your prompt to yellow:
What you’ll notice is that the prompt stays colored but all other text is not. But this is just the beginning of what you can do. You can create special escape sequences and the ANSI driver interprets them. I found a good resource on the ANSI escape codes here.
And if you really want to get adventurous, try this:
PROMPT $E[s$E[1;1H$E[0;1;33;41m$E[K $P$G$E[1;54H$D $T$H$H$H$H$H$H$E[36;40m$E[u $P$G $E[37m
You can see a screen shot of the result here.
Tech HelpJust An
Got a Windows, Exchange or virtualization question
or need troubleshooting help? Or maybe you want a better
explanation than provided in the manuals? Describe
your dilemma in an e-mail to the MCPmag.com editors
the best questions get answered in this column and garner
the questioner with a nifty Redmond T-shirt.
When you send your questions, please include your
full first and last name, location, certifications (if
any) with your message. (If you prefer to remain anonymous,
specify this in your message, but submit the requested
information for verification purposes.)
The only downside I’ve discovered so far is that the Ansi.com program disables my command buffer. And the Up arrow, F3 or F7 commands no longer work. But if you never use them, you won’t miss them and you can have an appealing prompt.
If you come up with a killer ANSI escape sequence for your prompt, I hope you’ll share with others by commenting at the end of this article.
Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.