Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
change the shell in console2 to powershell. It is much more powerful that the cmd shell. –  nXqd Jun 23 '12 at 8:47

2 Answers 2

up vote 6 down vote accepted

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"
    
share|improve this answer

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 $*
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.