1 min read
A complete guide to configuring fast shell shortcuts in Zsh, Bash, and PowerShell
Posted byThức Trần

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:
echo $SHELL
Step 2: Open your shell profile (~/.zshrc for Zsh or ~/.bashrc for Bash) in your editor:
nano ~/.zshrc
Step 3: Add your desired shortcuts at the bottom of the file:
# Shortcuts alias pn="pnpm" alias dev="pnpm dev" alias g="git" alias gs="git status" alias gco="git checkout"
Step 4: Reload your terminal profile to apply the changes immediately:
source ~/.zshrc
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:
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
Step 2: Open your profile file in Notepad or VS Code:
notepad $PROFILE
Step 3: Add functions for complex commands or simple aliases:
# Simple alias Set-Alias -Name pn -Value pnpm # Function with arguments function tf { terraform $args } function gco { git checkout $args }
Step 4: Save and reload your session in PowerShell:
. $PROFILE
Now you have fast, unified terminal aliases regardless of whether you are working on macOS or Windows.
Posted by