Console 2 command aliases

Console2 is only a wrapper around hidden Win32 console windows and does not provide extended line editing functionality.

You can create aliases in Win32 consoles:

doskey d=dir $*

Unlike Unix sh, you have to explicitly specify $* to append given arguments (ex. d C:\). You can also use $T to separate commands.

Also unlike Unix, aliases are implemented at Win32 console level, not in Console2 or the cmd.exe shell. This also means that you can use them in any program that reads interactive input. (For example, doskey /exename=python.exe h=help($*) would translate h sys to help(sys).)


To load the aliases automatically for cmd.exe (Command Prompt):

  1. create a batch script (for example, %APPDATA%\autorun.cmd) with the doskey commands. Example:

    @doskey d=dir $*
    

    Example to read multiple aliases from a file:

    @doskey /macrofile=%APPDATA%\cmd.aliases
    
  2. set the HKCU\SOFTWARE\Microsoft\Command Processor value AutoRun to the path of your "autorun" script:

    C:\> reg add "HKCU\SOFTWARE\Microsoft\Command Processor" /v AutoRun /t REG_SZ /d "%APPDATA%\autorun.cmd"
    

Although this question is over a year old and already answered, the following solution is simpler and avoids editing the registry:

In Console2, go to Edit > Settings. Change the "Shell:" field to the following:

C:\Windows\system32\cmd.exe /K "C:\Path\to\aliases.cmd"

Now restart Console2 and you're done.

To possibly save you some time, here's a simple example of an aliases.cmd file:

@echo off

DOSKEY clear=cls
DOSKEY ls=dir
DOSKEY ex=explorer .
DOSKEY ll=dir /A
DOSKEY rm=del $*