Windows: Command Line Aliases

15/10/13
Share
Unfortunately, Windows default command interpreter (cmd.exe) does not include support for command-line aliases, as in bash, zsh and other /bin/*sh type shells that can be found in the world of Linux. This can be partially corrected. To implement the use of aliases we can use a simple program called “Doskey”:
  1. Create a file that will store our aliases (in Doskey terminology – “macroses”), for example, C:\Users\a\etc\a.doskey.
  2. Type in the command to automatically setup the aliases/macroses at the start of command interpreter to the registry.
To do this, let’s change the value of the AutoRun key of the following thread in the registry: «HKEY_CURRENT_USER\Software\Microsoft\Command Processor» to the following: doskey /macrofile=C:\Users\a\etc\a.doskey (if there is no AutoRun key, then you should create it). And that’s it. A couple of examples now: Let’s add the following lines to C:\Users\a\etc\a.doskey:
.doskey-edit=notepad C:\Users\a\etc\a.doskey 
.doskey=doskey /macrofile=C:\Users\a\etc\a.doskey 
svnh=svn help $* | more 
svnhelp=svn help $* | more 	
svnco=svn co $*
Lines 1 and 2 are service commands to edit and update the aliases in the current command interpreter. Lines 3, 4 and 5 are several aliases for working with SVN ($* means the assignment of all arguments of the command-line to macros). Alternatively, you can create a separate bat-file for each alias, but the solution using aliases may be more elegant.

Sources:

Sign Up for Updates!

Subscribe now to receive industry-related articles and updates

Choose industries of interest
Thank You for Joining!

You will receive regular updates based on your interests. No spam guaranteed

Add another email address
Read more
DataArt + Microsoft

DataArt has extensive experience with Microsoft stack and helps clients develop, integrate and optimize Microsoft-based solutions that drive innovation and growth.

Learn more
Sign Up for Updates!
Choose industries of interest
Thank You for Joining!

You will receive regular updates based on your interests. No spam guaranteed

Add another email address
Welcome
We are glad you found us
Please explore our services and find out how we can support your business goals.
Get in Touch