Adding Shortcut Commands to CMD
Are Adding Shortcuts Really Necessary ?
Well the answer is "it depends". Personally I like these sort of shortcuts in place. It helps me to focus on things that I want to do. But there are some people who like to type things out, whatever you do or like, these methods might be beneficial to you.
Doskey
This is the single important piece of word that will help you to "macro" or "alias" any command or a group of commands. Please check Microsoft Doskey for more on Doskey and its uses.
Basically it allows us to initialise dos commands and use them with CMD or windows terminal.
These are few commands that I use for my python environment
@echo ============================================
@echo Hello {Your Name} %DATE%
@echo Starting Macros {as per instructions}
@echo Ready...
@echo ============================================
@echo off
DOSKEY mdn = mkdir newfolder
DOSKEY calljup = ssh -L 8080:localhost:<PORT> <REMOTE_USER>@<REMOTE_HOST>
DOSKEY history = doskey /history
DOSKEY fenv = conda activate <YOUR ENV>
DOSKEY senv = conda activate <2nd ENV>
Steps:
Create a new file called alias_macros.cmd.
Paste the above commands or similar commands in the file and save it.
Copy the full path of alias_macros.cmd.
Press Win + R or Win + S to open regedit
Type Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor in address bar
Create a new key > AutoRun
Modify AutoRun > Paste the full address of alias_macros.cmd
Close Regedit
Now whenever you open a new cmd something like this will open :
Explanation of commands in alias_macros.cmd
@echo : used as an equivalent of print
%DATE% : used to get date in the system specified format
{YOUR NAME} : You can replace this position with your name
@echo ============================================`
@echo Hello {Your Name} %DATE%
@echo Starting Macros {as per instructions}
@echo Ready...
@echo ============================================
@echo off: Turns off echo/print
DOSKEY mdn = mkdir newfolder : Create a new folder named newfolder using mdn
DOSKEY calljup = ssh -L 8080:localhost:<PORT> <REMOTE_USER>@<REMOTE_HOST> : Script to call jupyter with SSH from remote server using calljup.
DOSKEY history = doskey /history : Type history to get history of the current window, works similar to history from linux.
DOSKEY senv = conda activate <ENV> : Activate your conda environment using senv.