DEV Community

Cover image for Stop Typing the Same Commands Over and Over: Bash Aliases for Lazy Developers
Mohamed Yaseen
Mohamed Yaseen

Posted on

Stop Typing the Same Commands Over and Over: Bash Aliases for Lazy Developers

A quick guide to automating repetitive terminal commands with bash aliases

We've all been there—typing the same git commands, npm scripts, or directory navigations 50 times a day. Your fingers hurt, your productivity suffers, and you're wasting mental energy on muscle memory instead of actual coding.

Here's the fix: bash aliases. Two minutes to set up, infinite time saved.

What's an Alias?

An alias is basically a shortcut command. Instead of typing the full command, you create a shorter version that does the same thing.

How to Set It Up

Open your shell config file:

nano ~/.bashrc
# or if you use zsh:
nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Add your aliases at the end:

# Git shortcuts
alias gs='git status'
alias ga='git add .'
alias gc='git commit -m'
alias gp='git push'
alias gl='git log --oneline'

# Navigation
alias ..='cd ..'
alias ...='cd ../..'
alias myproject='cd ~/projects/my-awesome-project'

# Common npm commands
alias ni='npm install'
alias nr='npm run'
alias ns='npm start'

# Quick docker
alias dps='docker ps -a'
alias dstop='docker stop $(docker ps -q)'
Enter fullscreen mode Exit fullscreen mode

Save and exit (Ctrl+X, Y, Enter if using nano).

Then reload your shell:

source ~/.bashrc
# or
source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Real-Life Example

Before:

cd ~/projects/my-webapp && npm run dev
Enter fullscreen mode Exit fullscreen mode

After:

mydev  # That's it!
Enter fullscreen mode Exit fullscreen mode

You just saved keystrokes and your carpal tunnel says thank you.

Pro Tips

  1. Keep it memorable - Use abbreviations you'll actually remember
  2. Don't override existing commands - Check before naming your alias
  3. Document complex ones - Add comments in your config file
  4. Share with your team - Add aliases to a dotfiles repo everyone can use

Bonus: Functions for Complex Tasks

If you need more than a simple shortcut, use a function:

# Create and navigate into a directory
mkcd() {
    mkdir -p "$1" && cd "$1"
}

# Kill process by name
killport() {
    lsof -ti:$1 | xargs kill -9
}
Enter fullscreen mode Exit fullscreen mode

The Real Win

Every second counts when you're grinding. These tiny automation wins add up to hours of reclaimed time over a year. More time coding, less time typing the same stuff.

Start with 5 aliases today. You'll thank yourself tomorrow.


What's your favorite time-saving alias? Drop it in the comments! 👇

#happycoding

Top comments (1)

Collapse
 
i_am_yaseen profile image
Mohamed Yaseen

.