Useful Aliases in Windows Command Prompt for Vagrant Users

The new Windows Terminal software has been released and by all accounts, the app should have been released in mid June but if you can’t wait till then to have some aliases in your command prompt, there is an alternative.

DOSKEY is a tool which adds command history, macros and better editing, apparently, but it’s the ability to use it for aliases that I will focus on here.

Fortunately, they are dead easy so let’s start by opening up a command prompt and when it appears, type this command:

> doskey c=cls

Now type:

> c

and press enter.

Shazam! You have saved yourself 2 characters of effort each time you want to clear the screen.

Quite useful, right? But close the command prompt and like a puff of smoke, the alias is gone. Let’s change gears and do something more useful and more permanent.

Starting with a fresh command prompt, create a folder on your C drive in the root called bin

> mkdir c:\bin

Now create a text file called alias.cmd in that folder:

> notepad c:\bin\alias.cmd

Say yes, when it asks you if you want to create a file. Next, add in these commands:

> doskey vu=vagrant up
> doskey vd=vagrant halt

and save the file.

Now we need to tell Windows to run this file every time you start a command prompt, so for that, we are going to edit the registry. Don’t worry, though (it’s a simple change); if you are concerned, you can always back it up under File…Export.

Back to command prompt:

> regedit

Click yes when prompted.

Now dig into the tree on the left and find the place named:

Computer\HKEY_CURRENT_USER\Software\Microsoft\Command Processor

On the right hand pane, right-click and choose New, then String Value.

Type AutoRun in the name column and press Enter.

Select the entry again, right-click, and choose Modify…

In the value field, type:

> c:\bin\alias.cmd

Click OK.

You can close regedit now.

Last thing to do is to test it so fire up a new command prompt and try out your alias. Of course, you will need to be in a homestead installation folder for these aliases, but if you used something else, it should work.


Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’ logicalmoon.com