More Menu
Reading ListGanti TemaSearch
Reading List

Queue · 0 items

Your reading list is empty. Save articles to read them later.

Start Reading

Stop Typing `npm run dev`: Create a Bash Alias in Linux

Iwan Efendi1 min
One of the most repetitive things I do every day is opening a terminal, navigating to my project folder (cd ~/Documents/SnipGeek), and running npm run dev. It gets tiring to type the exact same string constantly. In Linux, you can create a bash alias—a permanent custom shortcut for any long command. Instead of typing that whole line, I just type snipgeek and the local server starts instantly. Here is how you can set it up for your own workflow.
1

Open your .bashrc file

The .bashrc file is a configuration script that Linux runs automatically every time you open a new terminal window. You can edit it directly using nano:
nano ~/.bashrc
2

Add the alias command

Scroll all the way down to the bottom of the file. I usually leave a blank line before adding my custom aliases to keep the file visually structured. Add this exact line:
alias snipgeek="cd ~/Documents/SnipGeek && npm run dev"
Replace snipgeek with whatever shortcut name you prefer, and adjust the folder path to match your actual project repository location.
3

Save and exit

Since we are using nano, you need to use keyboard combinations to save your changes:
  • Press Ctrl + O to save.
  • Press Enter to confirm the filename.
  • Press Ctrl + X to exit the editor.
I used to forget this flow and accidentally close the terminal without saving, so memorizing these shortcuts early is surprisingly helpful.
4

Apply the new configuration

By default, the terminal won't recognize your new alias until you close and reopen it. To apply the changes immediately without closing the current window, run:
source ~/.bashrc
5

Test your new shortcut

Now you are done. From anywhere in your terminal, simply type your alias name:
snipgeek
My terminal quickly jumping to the main project directory and booting up the development server.
If the directory path is correct, your terminal will instantly jump to the project folder and fire up the development server.
Using Zsh instead of Bash?
If your system defaults to zsh instead of bash (you can check by running echo $SHELL), the configuration file is different. You need to edit ~/.zshrc instead of ~/.bashrc. The rest of the setup is exactly the same.

More Alias Ideas

If you have a habit of navigating to your specific folders manually, you can create a simpler alias just for starting the server:
alias dev="npm run dev"
You are not limited to one alias. I rely heavily on these short forms during busy days to handle quick Git operations or open my code editor seamlessly:
alias gs="git status"
alias gp="git push"
alias code.="code ."
Little things like this are what make working in Linux such a joy. You spend two minutes configuring things once, and it smoothly saves you time every single day. Give it a try, and tweak your own terminal space into something that perfectly fits your development habits!
Topics

Topics in this note

Explore related ideas through the topics connected to this note.

Share this article

Discussion

Preparing the comments area...

You Might Also Like