DEV Community

Dendi Handian
Dendi Handian

Posted on • Updated on

Alias your Commands using DOSKEY

I will make this tutorial short and straightforward with my case. So I have been using Docker CLI on Windows for a long time, the commands are really long to type and make you less productive. So I start to find the solution and this Doskey thing come in handy and make my life easier.

NOTE: I have successfully implemented it on `Command Prompt`, not `PowerShell`. So I will find a way to implement it later on PowerShell.

So let's get started to alias your commands!


Create your aliases command file

Let's start to make a file to store your commands permanently. For example, I have created a file with the path C:\Users\dendi\Documents\MEGASync\Doskey\macros.doskey and fill it with my most used docker commands and alias them like this:

dcps=docker-compose ps
dcud=docker-compose up -d
dcd=docker-compose down
dcs=docker-compose stop
dcl=docker-compose logs
dce=docker-compose exec
dcudnmp=docker-compose up -d nginx mysql phpmyadmin
dceulwb=docker-compose exec --user=laradock workspace bash
Enter fullscreen mode Exit fullscreen mode

Of course you can create the file on any folder you want, but this is my example case for the following configuration.


Register the alias commands

Click Start menu or hit the Windows key on your keyboard, then start to type 'registry editor' and enter the matched program.

Find the HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\ directory on the tree structure in the left screen. Right click on the Command Processor folder and choose the New > String Value.

doskey-3

It will create the a new file on the folder and named it to Autorun. Then right click on Autorun file, choose Modify and fill the Value data with (use your own file path) :

DOSKEY /MACROFILE="C:\Users\dendi\Documents\MEGASync\Doskey\macros.doskey"
Enter fullscreen mode Exit fullscreen mode

doskey-4

Click OK and that's it. To make it in effect, just a new Command Prompt instance.


Check the registered commands

Now you can open your Command Prompt program and execute this command to see your alias list:

doskey /MACROS
Enter fullscreen mode Exit fullscreen mode

If you see your alias commands, then it should be work.


Have fun exploring DOSKEY!

Top comments (0)