Custom command line shortcuts with Doskey

I’ve learned this nice trick from Petr Horáček aka Besir while working on Nakamotox. So the credit goes to him.

You can define custom commands via doskey (only on Windows) and then invoke them via command line. It is quite powerfull, because you can define alias for command with predefined attributes, so it save you lot of repetitive typing.

Steps:

  1. Open any text editor and define your shortcut commands
@echo off
REM example shortcut for docker-compose
doskey dcdu=docker-compose -f docker-compose-dev.yml up
doskey dcdd=docker-compose -f docker-compose-dev.yml down
  1. Add path to file with commands to registry:
  2. open regedit
  3. go to \HKEY_CURRENT_USER\Software\Microsoft\Command Processor
  4. define AutoRun
  5. enter path to file with doskey commands