❓The Problem
In the 22 years that I’ve been using a computer, my OS usage breakup is 12 years : 3 years : 7 years for Linux : Mac : Windows. So you know that for 15 of the 22 years, I’ve enjoyed the privilege of being able to use the `alias` command and just setting shortcuts to terminal commands as I see fit.
In the last few years though, since coming to Windows (for work), I’ve sorely missed them.
A quick search told me that I could use Powershell and aliases were supported there. But somehow Powershell hasn’t ever appealed to me the way a Unix terminal did. There was the compromise - WSL. But that has its own limitations. My last viable option was that I could use batch commands as a proxy to these aliases. I grabbed onto it like a drowning man to a life jacket.
Since then, I’ve created almost 50 batch files - manually.
The effort didn’t matter. I had shortcuts. This is what a batch file looks like -
Now there are two barriers to this being an easy process to a developer.
Having to create a new file at this path every time I need to create a new shortcut.
Writing the CMD equivalent of what I need to do in the batch script.
While step 2 is the topic for a later day, I’ve tried to make the process to step 1, a little more Pythonic.
⚙️ The Solution (part of it, atleast)
I’ve created and published a Python package called `win-alias` that will make this process more fun.
Here’s how it can be used -
Create a virtual environment (using `uv` by now hopefully)
Install win-alias - `uv pip install win-alias`
To create a new alias, use :
win_alias create-alias
You will be prompted to enter the name of the alias and the command that this is to be mapped to.
EOF is the way to indicate that the command you want to map the alias to is complete.
If your home directory is at `C:\Users\abhiram`, the alias is created at `C:\Users\abhiram\aliases`. For the first time you create an alias, put the path to this folder in your PATH environment variable.
Voila! You have your first alias in Windows :)
To check out the package on Pypi, here you go - https://pypi.org/project/win-alias/
As of now, the supported commands are to create an alias and to list all the available aliases.
I will be improving on this soon since it’s a project very close to me and my daily productivity :)
📚 Additional Reading -
https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-alias?view=powershell-7.5
This package is actively under development! Create a Github issue if you want a feature added or raise a PR and associate it with an issue if you want to contribute :)