Developer Productivity: Shell Aliases, Functions, and Tiny Scripts

Automate boring terminal work: safe aliases, parameterized functions, and one-file scripts you can commit to dotfiles.

Productivity & workflows Beginner 5 min read

·

Shell aliases and functions shorten repeated commands but run in your user context—so they should never hide destructive operations. You load them from rc files so every new terminal inherits the same shortcuts; you use functions when aliases cannot take arguments cleanly.

Aliases

Why alias git status: Typed hundreds of times per week; shortening reduces friction without changing behavior.

alias gs="git status"
alias dc="docker compose"

Put them in ~/.bashrc, ~/.zshrc, or a sourced ~/.aliases file.

Check: Open a new shell and run type gs—should show the alias expansion.

Functions for parameters

Why a function for mkcd: Aliases cannot reliably take a directory name and chain mkdir + cd with error handling.

mkcd() { mkdir -p "$1" && cd "$1" || return; }

What || return does: Stops if mkdir fails (permissions, invalid path) instead of cding elsewhere.

Project shortcuts

Why direnv: Automatically loads per-project env when you cd—avoids exporting secrets globally. Ties to secrets hygiene.

Scripts in Git

Why commit scripts: Teammates run the same ./scripts/dev-up.sh instead of copying brittle commands from wiki pages. Pair with Git and CI.

Frequently asked questions

Aliases vs Makefile?

Aliases are personal; Make targets document team workflows and tab-complete nicely.

Windows?

PowerShell profiles and WSL both work; pick one primary shell per project.

Portable scripts?

Start with #!/usr/bin/env bash and set -euo pipefail for safer defaults.

Security?

Do not curl | bash without verifying the source; same for copied dotfiles.