Setting up the command prompt

Since getting used to the terminal in ubuntu and on my mac, I have got used to using ls and ll and other unix commands, which by default don't work in the windows 7 command prompt.

Well, with a combination of a few applications, and some configuration I've got nicely coloured terminal output, and unix style commands in my windows 7 command prompt.

I use the fantastic Console2 application as my main console application, I've also installed ansicon which is an ansi escape sequence processor that helps to show the ansi colour codes in the command prompt. To enable the unix style commands I installed cygwin, and added the cygwin\bin folder to the system path environment variable.

If you run ansicon with the -i/-I parameter it will install itself into the command prompt by modifying the registry as follows, -i will modify HKCU and -I will modify HKLM:


"Software\Microsoft\Command Processor\AutoRun"

It will set the data property to the path to ansicon. These reg keys get run every time a command prompt is started. I moved the command to a bat file I created called "startup.bat", and replaced the data property with the full path to the bat file.

"doskey" is the command prompt equivalent of the unix "alias" command, it needs to be run at startup as well, and pointed at a file that contains the macros it should load. So that can go in the startup.bat file as well. The bat file looks like this:

"D:\Program Files\AnsiCon\x64\ansicon.exe" -p
doskey /macrofile="D:\Program Files\Console2\doskey.txt"

Then my macrofile looks like this so far:

ls=ls -F --color=tty
ll=ls -laF --color=tty
edit=notepad $*

It'll be easy to add more aliases into the doskey.txt file as I need them, or to add more commands to startup.bat as I need them too.


I edited the notepad line in the doskey file above and added the $* parameter, which tells doskey to pass whatever is on the command line that is not the macro name and has not been assigned to numbered parameters. Essentially it passes the rest of the command line to notepad so it will open the file you specify.

I also modified another registry key: HKCR\Directory\shell\cmd\command, and set the default value to "D:\Program Files\Console2\x64\Console.exe -d %1"

This changes the 'Open Command Window Here' context menu to open Console2 rather than the default command prompt.

Comments are closed