.bashrc is a very useful file in Linux environments. It basically runs every time a new Linux shell is opened & you can add commands like aliases. I wanted to have something similar in windows. After searching over internet I have found the following technique.
- create a .bat file with the command name in a directory. (for example if you want to use
lsto list directories create a file with the name ls.bat in C:\myBatCommands with
- add the folder(C:\myBatCommands) to PATH environment variable
- you can start using the commands.
This looks simple but every time you want to add a command you need to create a new file with the name in the folder. so create a .bat file(something like cmdrc.bat) to simplify this with following content.
@echo off set filename=%~1 set command=%~2 echo %command% > C:\myBatCommands\%filename%.bat
Anytime you want to add a command to the folder run the following command.
#cmdrc <alias-name> <command> cmdrc ls dir
There are couple of other ways listed here. If there are any others ways of achieving the same please post in comments.
If you are using powershell you can use profile.ps1 with all the aliases. for more info.
Top comments (0)