Emulate the MS-DOS prompt
If you miss the MS-DOS times :), here is how to emulate the DOS prompt in bash.
Version #1
Here is the basic version:
export PS1='C:\w> '
To make it permanent, add it to your ~/.bashrc file :)
Result:
C:/> cd /tmp C:/tmp> cd /etc/grub.d/ C:/etc/grub.d>
Version #2
Here is how to replace the ‘/‘ characters to ‘\‘ in the prompt path. First, add the following function to your ~/.bashrc:
function msdos_pwd {
echo `pwd` | tr '/' '\\'
}
Then, either source ~/.bashrc, or open a new terminal window.
Finally, set PS1 like this:
export PS1='C:`msdos_pwd`> '
Result:
C:\> cd /tmp C:\tmp> cd /etc/grub.d/ C:\etc\grub.d>
Improvement #1:
If you want to see ‘~’ instead of full path when you enter your HOME directory, use this function:
function msdos_pwd
{
if [ "`pwd`" == "$HOME" ]
then
echo '~'
else
echo `pwd` | tr '/' '\\'
fi
}
Improvement #2 (update 20110210):
The previous version showed ‘~’ in the HOME directory only. When you entered a subdirectory of HOME, HOME was expanded. Here is the revised version:
function msdos_pwd
{
local dir="`pwd`"
dir=${dir/$HOME/'~'}
echo $dir | tr '/' '\\'
}
Links
- To learn more about setting PS1, refer to this post.
- Bash Reference Cards (String Operations)
- Bash Local Variables
Similar work (update 20110210)
As I was browsing the web looking for something alike, I found a similar approach. His implementation is different and he doesn’t replace the HOME directory by ‘~’.
Blinking cursor (update 20110304)
In MS-DOS, the cursor was a blinking underscore. Here is how to set it under Konsole: Settings -> Configure Profiles… -> Edit Profile… -> Advanced tab. Here, under the Cursor section, tick Blinking cursor and for cursor shape select “Underline”. Apply, OK. Close konsole and open a new instance.
Final touch (update 20110311)
To make it even better, let’s print some MS-DOS boot text when opening a new shell. Add these lines to the end of your ~/.bashrc file:
echo Starting MS-DOS... echo echo echo HIMEM is testing extended memory...done. echo
You can download everything here.

Screenshot of the final product.
Update (20120927)
On reddit, someone suggested the following one-liner:
export PS1='C:${PWD//\//\\\\}>'