Typing repetitive terminal commands multiple times a day slows down your workflow. Setting up shell aliases allows you to turn lengthy commands like pnpm run dev or terraform init into quick 2-letter shortcuts like pn dev or tf init.
On macOS (default shell is Zsh) and Linux (Bash), aliases are stored in your user profile configuration file.
Step 1: Identify your active shell by running:
Step 2: Open your shell profile (~/.zshrc for Zsh or ~/.bashrc for Bash) in your editor:
Step 3: Add your desired shortcuts at the bottom of the file:
Step 4: Reload your terminal profile to apply the changes immediately:
On Windows, PowerShell uses a profile script that executes whenever a new terminal session starts.
Step 1: Check if your PowerShell profile exists or create one:
Step 2: Open your profile file in Notepad or VS Code:
Step 3: Add functions for complex commands or simple aliases:
Step 4: Save and reload your session in PowerShell:
Now you have fast, unified terminal aliases regardless of whether you are working on macOS or Windows.