Lifesaver “Alias/Shortcut” feature for coders

Pintu Prajapati
2 min readJun 13, 2023

Prologue

Let’s face it — we’ve all experienced the daunting task of wrestling with those mid-sized command lines.

For example, let’s have a look at django commands

In Django, people use three command more often than others.

such as

python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver

And this is just scratching the surface — every language, framework, or service has its own set of frequently used commands.

Sure, some might argue that the “up arrow key” (↑) can be used to recall previuos commands, but let’s be honest : endlessly scrolling up to find the desired command can become an challenging task, especially when you’ve used plethora of them

But fear not, dear reader, because I present to you the ultimate solution — an invaluable feature that has transformed my daily life and brought me nothing but sheer joy (yes, even a touch of it XD)

Behold, the Arrival of a Savior: Introducing the Mighty Alias

Create alias command:

1) Open cmd

2) Type this command: nano ~/.bashrc

3) Now you have to add alias in .bashrc file:
- Scroll to the both of the file
- Now here, you just type in this manner

Syntax: alias <alias_name> = "<command>"

ex: alias django="python3 manage.py runserver"
ex: alias testenv="source ../testenv/bin/activate"

4) Execute the following command to make the changes take effect:
- Ctrl+O (this is english 'O', not 'zero')
- Press Enter
- Ctrl+x to exit

5) Restart the terminal (kill the current terminal and reopen)

6) Now type the alias_name and it will take effect
- for example, in cmd, just type your alisa_name

Syntax: <alias_name>

ex: django (it will run the django server)
ex: testenv (it will run the virtual env)

Below I’ve given some image references to understand it easily.

bashrc file — Set alias_name for the commands which you think that will need to be used many times
Reopen/Restart the terminal and just type alias_name and the respective command will run

Don’t hesitate to reach out if you need further clarification or find yourself in need of additional assistance.

Understanding complex concepts can sometimes be a challenge, and I’m here to help you every step of the way.

Stay tuned (🔔) for more invaluable tips and tricks in the future by following me (👉). Your support is greatly appreciated. Thank you! 🙏

--

--

Pintu Prajapati

Software Engineer | Python | Django | AI | Blockhchain | NFT etc...