Back in school, I used to have a .login file along the lines of
alias ll = ls -l
alias dir = ls -Fhl
alias web = cd ~/public/public_www/development
I'd like to do that sort of thing with my XP box here at work, but most of the resources I've found online seem fairly complicated and heavy-duty. Is there a way to do this that doesn't involve mucking about in the registry or running a large batch file?
My original reason for asking this was that I only need the command line for one command in one specific folder, and I wanted to be able to get to that folder quickly when I launched the command line. But the accepted answer for this question is so good that I decided to ask about my original issue as a separate question: Change to default start folder for Windows command prompt.
Best Answer
Not many people seem to know about it, but you can use the
doskey
built-in macro tool, the only issue is that it doesn't save. There are many ways to work around this though.usage:
ls
will now do a directory listing just likedir
would.If you want to use arguments with the commands, use this syntax:
As for the workaround to make them save:
and place it in one of the directories in your path. Name it something short like a.cmd, so when you open cmd you can type a to load your aliases.
If typing an a and pressing Enter seems too much work, throw this into your AutoHotkey script:
Loading aliases automatically:
You can change all shortcuts to cmd to point to
%SystemRoot%\system32\cmd.exe /K C:\path\to\aliases.cmd
, replacingC:\path\to\aliases.cmd
with the location of your aliases file. If you typically run it from the run box, you can: