Useful Bash Aliases for Developers (With Examples)

2026-06-25 — 7 min read

An alias is a one-time investment. You type it correctly once, add it to your shell config, and from that point forward it saves keystrokes every single day. The hard part isn't the syntax — it's knowing which ones are actually worth making permanent.

These 30 aliases are the ones that hold up: they cover git, navigation, file management, and the system shortcuts developers reach for constantly. Each one includes an explanation so you understand what you're adding to your shell, not just copying something opaque.

Contents

  1. How to add an alias
  2. Navigation
  3. File operations
  4. Git shortcuts
  5. System & processes
  6. Developer workflow
  7. FAQ

How to Add an Alias

Aliases defined at the command line vanish when you close the terminal. To make one permanent, add it to ~/.bashrc (bash) or ~/.zshrc (zsh):

echo "alias ll='ls -lAh'" >> ~/.bashrc
source ~/.bashrc

The source command reloads the file in your current shell without restarting it. Or you can keep all your aliases in a separate ~/.bash_aliases file and load it from your ~/.bashrc:

# In ~/.bashrc:
[ -f ~/.bash_aliases ] && source ~/.bash_aliases

This keeps your rc file clean and makes it easy to sync aliases across machines.

Better directory listing

alias ll='ls -lAh'
alias la='ls -A'

-l is long format, -A shows hidden files (but not . and ..), -h makes sizes human-readable. ll is the single most-typed alias in most developers' configs.

Jump up multiple directories

alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

Three dots drops you two levels up, four dots drops you three levels. Much faster than repeated cd .. when you're deep in a project tree.

Go home and common directories

alias ~='cd ~'
alias projects='cd ~/projects'

Adjust the path to wherever you actually keep your work. The goal is zero friction for your most-entered destinations.

Show the last five visited directories

alias dh='dirs -v | head -5'

Bash maintains a directory stack with pushd/popd. dirs -v shows it with indices. Use cd ~2 to jump to index 2.

File Operations

Safe versions of destructive commands

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'

The -i flag prompts before overwriting or deleting. This costs one keystroke on the rare occasions you're sure — and has saved countless files from fat-fingered rm commands. Some people disable these on servers where automation runs without a TTY; on a dev machine they're almost always worth keeping.

Make a directory and immediately enter it

alias mkcd='_(){ mkdir -p "$1" && cd "$1"; }; _'

This is actually a tiny function disguised as an alias. The mkdir -p creates parent directories as needed. Use it: mkcd new-project/src/components.

Find large files quickly

alias bigfiles='find . -type f -size +10M | sort'

Scans the current directory tree for files over 10 MB. Adjust the threshold with +50M or +1G. Pair with ls -lh $(bigfiles) to see sizes.

Show disk usage for the current directory, sorted

alias ducks='du -sh */ 2>/dev/null | sort -h | tail -20'

sort -h understands human-readable suffixes (K, M, G). 2>/dev/null suppresses permission errors. This is the first thing to run when a disk fills up unexpectedly.

Git Shortcuts

Git's long subcommands are the most natural target for aliases. These assume you're in a git repository — they don't add safety checks, so know what they do before you use them.

The status shortcuts

alias gs='git status'
alias gss='git status --short'

--short gives a compact two-column view: M for modified, ? for untracked. Good when you already know the broad state and just want to confirm.

Staging and committing

alias ga='git add'
alias gaa='git add --all'
alias gc='git commit -m'
alias gca='git commit --amend --no-edit'

gc "message" lets you commit in one shot. gca amends the last commit without opening an editor — use it when you forgot to stage a file or made a typo in the commit. Only safe before you push.

Log views

alias gl='git log --oneline --graph --decorate -20'
alias gla='git log --oneline --graph --decorate --all'

gl shows the last 20 commits with a visual branch graph. gla shows all branches. These two together replace most of what a git GUI gives you.

Branch management

alias gb='git branch'
alias gco='git checkout'
alias gcob='git checkout -b'

gcob feature-name creates and checks out a new branch in one step.

Push and pull

alias gp='git push'
alias gpu='git push -u origin HEAD'
alias gpl='git pull'

gpu pushes the current branch and sets its upstream in one command — useful when you create a new branch locally and want to push it for the first time.

Undo the last commit (keep changes staged)

alias gunstage='git reset HEAD~1 --soft'

Moves HEAD back one commit but leaves the files staged. Safe for undoing a premature commit. Don't use after pushing — use git revert for shared history.

System & Processes

Quick process search

alias psg='ps aux | grep -v grep | grep'

Usage: psg node. The grep -v grep filters out the grep process itself from the results. Faster than ps aux | grep X | grep -v grep every time.

Show what is listening on a port

alias listening='lsof -i -P -n | grep LISTEN'

Lists all open network ports with PID and process name. -P shows port numbers instead of service names, -n suppresses hostname lookups so it runs immediately.

Reload shell config

alias reload='source ~/.bashrc'

After editing ~/.bashrc, one word reloads it. For zsh users: alias reload='source ~/.zshrc'.

External IP address

alias myip='curl -s ifconfig.me'

Prints your public IP. Useful when debugging firewall rules or confirming a VPN is working.

Developer Workflow

Copy the last command to clipboard

# macOS
alias clip='fc -ln -1 | pbcopy'
# Linux (needs xclip)
alias clip='fc -ln -1 | xclip -selection clipboard'

fc -ln -1 prints the last command from history. Pipe it to a clipboard tool to paste it somewhere else — a Slack message, a Notion doc, a script.

HTTP server from any directory

alias serve='python3 -m http.server 8080'

Starts a static file server in the current directory. Works for previewing HTML files locally. Change the port if 8080 is taken.

Timestamp every output line

alias ts='gawk "{print strftime(\"[%H:%M:%S]\"), \$0; fflush()}"'

Pipe slow commands through it: npm install | ts. Each line gets a timestamp prefix so you know how long each phase takes.

List your most-used commands

alias topcommands='history | awk "{print \$2}" | sort | uniq -c | sort -rn | head -20'

Run this after a few months with your current setup. The top results are your best alias candidates — anything in the top 10 that isn't already aliased probably should be.


FAQ

Where do I put bash aliases to make them permanent?

Add them to ~/.bashrc (bash) or ~/.zshrc (zsh). After editing, run source ~/.bashrc so the current shell picks them up without restarting.

What is the difference between a bash alias and a bash function?

Aliases are simple text substitutions — use them for fixed commands with no arguments. Functions accept arguments and can contain logic, loops, and conditionals. If you need to pass arguments or run multiple commands with branching, write a function instead.

Can I use bash aliases in shell scripts?

By default, aliases are not expanded in non-interactive shell scripts. They work in interactive shells (your terminal). If you need reusable shortcuts in scripts, define them as functions in a sourced file instead.

How do I list all my current bash aliases?

Run alias with no arguments. It prints every alias defined in the current shell session, including those loaded from .bashrc.


These are the ones worth keeping. The real test: if you add an alias and keep reaching for the long form out of habit, delete it. Aliases only pay off if muscle memory catches up.

Next up: 25 bash one-liners for finding files, processing text, managing processes, and working with git.