Ever tried to ls or rm under Windows?
With just a few minor adjustments the Windows Command Prompt (cmd.exe) can emulate the behaviour of your favourite *nix shell. Please note, this isn’t a full emulation method – the existing Windows commands are being manipulated to appear as their *nix shell counterparts.
This method involves simple implementation of the doskey macro utility. For convenience, a Windows batch file (*.bat) will be used to wrap calls to doskey. Some small adjustments to the registry are necessary, so it is strongly advised that the registry is backed up before reading further.
Create a Command List Batch File
- Open a text editor of your choice (e.g. notepad).
- The following are some examples of how to add a *nix command, with the Windows Command Prompt equivalent:
doskey sudo=runas /user:administrator $*
doskey alias=doskey $*
doskey ls=dir $*
doskey rm=del $*
doskey cp=copy $*
doskey mv=move $*
doskey reboot=echo The system is going down for reboot NOW!$T shutdown -r
doskey traceroute=tracert $*
doskey kill=taskkill /F /IM $*
echo [%USERNAME%@%COMPUTERNAME%]$ *nix commands added
- Save as a batch file somewhere on your system, e.g. C:nix-cmd.bat
Please note: Not all commands will behave exactly like their counterpart, however these are some examples from my batch file.
Enabling Batch File and Tab-key Auto-complete
- To add auto-complete for…
… just your username:
… all system users:
- Modify the key entries to reflect your system settings, although they should appear somewhat similar to the below:
If you want to use a different key for auto-complete (i.e. not tab), then change the CompletionChar and PathCompletionChar values to the desired hexadecimal character code.
That is all there is to it! I mostly make do with the commands above – its just a nice little tweak to make the command prompt a bit more usable.