Console 2 command aliases

8

6

I use Console 2 and I would like to create some aliases for commands I use often. Maybe my google-fu just sucks today but I cannot figure out how to do this. Any help would be appreciated thanks.

StevenMcD

Posted 2011-05-26T14:11:38.687

Reputation: 379

change the shell in console2 to powershell. It is much more powerful that the cmd shell. – Dzung Nguyen – 2012-06-23T08:47:46.717

Answers

7

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"
    

user1686

Posted 2011-05-26T14:11:38.687

Reputation: 283 655

12

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 $*

Alex Krycek

Posted 2011-05-26T14:11:38.687

Reputation: 343