Doskey: creating aliases under Windows command prompt
June 30, 2010 at 6:02 pm 1 comment
I’m tired of typing “ls” on an Windows command prompt and getting bounced back with an error. Aliases are truly a necessity. To simulate the behavior of “alias” on Windows, do the following:
1. Create a shortcut for cmd.exe, right-click on the shortcut and choose “properties” and proceed as follows.
2. Change the “start in” directory to your personal choice, such as “%HOMEDRIVE%%HOMEPATH%”
3. Create a batch file, such as “set_alias.bat”, in the “start in” directory. The file should contain the doskey command that loads the alias definitions. A sample file would contain this line:
doskey /MACROFILE=aliases.txt
4. Edit all your aliases.txt file, or other files that contain the Macros. For example, aliases.txt could look like this:
ls=dir $*
cp=copy $*
python2=C:\Python26\python26.exe $*
python3=C:\Python31\python31.exe $*
$* allows you to take an arbitrary number of arguments and pass that to the program (up to 9?)
5. At the end of “Target” line in the shortcut properties, add your batch script with “/K” option to run upon launching. The Target line should look similar to this:
C:\Windows\System32\cmd.exe /K set_alias.bat
Done! Now cruise along
1.
zac | August 1, 2010 at 10:14 am
You could also install the Interix subsystem for Windows. It has native unix utils for Windows