Customize Windows Command Prompt To Look Like A Bash Shell Prompt

3

vista.jpgI use both Linux and Windows Computers at work and have a need to use the command prompt on Windows. By default, Windows command prompt displays the current directory path. One problem with this is when you switch to a directory that has a long name, the prompt can end up half way across the screen. How can I change the prompt to look like a Bash shell prompt?


   

That is one drawback with Windows command prompt when the directory path name is long, the prompt ends up half way across the screen:

C:\Program Files\Microsoft Visual Studio\Common\IDE\IDE98>

With such a moving target that the command prompt can be at times, it can also be changed very easily by using the Prompt command.

The syntax for the Prompt command follows:

PROMPT [text]

where text specifies a new command prompt that can be made up of System and User variables, normal characters and the following special codes:

  • $A & (Ampersand)
  • $B | (pipe)
  • $C ( (Left parenthesis)
  • $D Current date
  • $E Escape code (ASCII code 27)
  • $F ) (Right parenthesis)
  • $G > (greater-than sign)
  • $H Backspace (erases previous character)
  • $L < (less-than sign)
  • $N Current driveprompt [%USERNAME%@%COMPUTERNAME%$S~]$$
  • $P Current drive and path
  • $Q = (equal sign)
  • $S (space)
  • $T Current time
  • $V Windows XP version number
  • $_ Carriage return and linefeed
  • $$ $ (dollar sign)

Say you wanted to make the prompt look like a Bash prompt on Ubuntu, Open a command prompt (go to Start \ Run… and type cmd then click OK) and enter the following Prompt command syntax:

prompt %USERNAME%@%COMPUTERNAME%:~$$$S

wincprompt1.png

Or you want the Prompt to look like a Bash prompt on Redhat Fedora:

prompt [%USERNAME%@%COMPUTERNAME%$S~]$$

wincprompt2.png

If you wanted to return the Prompt back to the default setting, just enter:

Prompt $P$G

When changing the prompt at the command line, it is only valid during the session. Once you exit or quit the prompt will return to its default value. To make the change permanent, you will need to make a Registry change.

Before Proceedingthe next step includes exporting the registry key to use as a backup if needed. DO NOT SKIP THIS STEP. As a safe guard, you may want to create a System Restore point when making configuration changes to your System.

  • Open regedit
  • Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
  • Right click on Environment and select Export to back up the Key to a location on your Computer (you may also want to copy to a  CD or USB drive that can be accessed if needed)
  • In the right Window Pane, right click and select New \ String Value and name it PROMPT
  • Double click on Prompt and in the Value data: field type the syntax for the Command Prompt you wan to use (for example – [%USERNAME%@%COMPUTERNAME%$S~]$$)
  • Close regedit and either logoff or reboot

The next time you open the Command Prompt, you new prompt will always be set.

 

Filed under Windows Tips by  #

Comments on Customize Windows Command Prompt To Look Like A Bash Shell Prompt Leave a Comment

October 29, 2007

Stasigr @ 5:09 pm #

Hello, very nice site, keep up good job!
Admin good, very good.

February 10, 2008

Anonymous @ 11:28 pm #

The result only superficially looks like a bash prompt, though; it does not reflect the current working directory.

October 5, 2008

Busedusite @ 4:13 pm #

well done, dude

Leave a Comment

Fields marked by an asterisk (*) are required.

Subscribe without commenting