Recently I facilitated problem that there is no easy way to create alias to most useful apps in Windows command line.  I found some hacks they require registry modifications and so one.  So because of lag of this feature I decided to simplify my workflow and I created simple Python script.

Solution is simple and quite straight forward. Each new alias will be created as a bat file with right name.  Assuming that main folder of aliases will be added to system PATH everything should work fine.

Script provides simple API:

  • add: add specific alias for given path
  • rem: remove alias with name
  • list: list all registered aliases
  • get: shows run script for specific alias

 

Features

  1. Create aliases for command line applications and GUI applications. GUI applications requires –fork flag to do not block command line until application stop.
  2. Pass invoke parameter of alias to destination program. Let’s assume that you created alias for notepad using:
    alias add n notepad --fork

    Not you would like to open some file using this alias:

    n test.txt

    Result will be as expected. Notepad will run with text.txt as a invoke parameter.

Installation

  1. Open command line
  2. Create folder for aliases:
    mkdir C:\Users\Piotr\aliases
  3. Add this folder to system PATH
    • “My Computer” > “Properties” > “Advanced” > “Environment Variables” > “Path”
    • Append to PATH:
      ;C:\Users\Piotr\aliases;
  4. Go to this folder:
    cd C:\Users\Piotr\
  5. Clone script:
    git clone https://github.com/trzcieu/alias.git .
  6. Register this script as an alias
    python C:\Users\Piotr\aliases\alias.py add alias python C:\Users\Piotr\aliases\alias.py
  7. Start to use alias command

Plans?

Depending on current needs, maybe I will add Linux, and MacOs support (but I assume they have own system for aliases).

Other nice feature it could be “setup” command which will register alias to invoke alias.py script. Will be great to auto register path to folder in system PATH.

More info and current state at: https://github.com/trzcieu/alias

 
1 Kudos
Don't
move!