Quick Answer

Terminal aliases on Mac let you create short custom commands for longer, repetitive terminal strings. Create them by adding alias entries to your ~/.zshrc or ~/.bash_profile file, then reloading your shell with source ~/.zshrc.

If you find yourself typing the same long terminal commands repeatedly - navigating to project directories, running build scripts, or connecting to servers - aliases will save you significant time every day. Mac''s default shell since macOS Catalina is Zsh, so most aliases live in ~/.zshrc. Here is a complete, practical guide to creating, managing, and using them effectively.

How to Create a Basic Terminal Alias on Mac

Open Terminal and type nano ~/.zshrc to open your Zsh configuration file. Add a new line in the format: alias shortname=''full command here''. For example, alias projects=''cd ~/Documents/Projects'' creates a shortcut that navigates to your Projects folder when you type ''projects''. Aliases with spaces in the command must be wrapped in quotes. After adding your aliases, save the file (Ctrl+X in nano, then Y to confirm) and run source ~/.zshrc to apply changes immediately without restarting Terminal. Your alias is now active for the current and all future terminal sessions.

Useful Alias Examples for Developers and Professionals

Some immediately useful aliases for Mac users: alias ll=''ls -la'' gives a detailed directory listing with hidden files. alias gs=''git status'' speeds up the most-checked git command. alias reload=''source ~/.zshrc'' lets you reload your config quickly after future edits. alias myip=''curl ifconfig.me'' returns your public IP address. You can also alias commands with arguments - alias py=''python3'' standardises the Python interpreter call if your system has multiple versions. Group related aliases with comments in your .zshrc using # comment lines to keep the file navigable as it grows.

Managing and Organising Aliases Long-Term

As your alias library grows, organising them inside ~/.zshrc with section comments keeps things manageable. For large collections, create a dedicated ~/.aliases file and source it from ~/.zshrc by adding source ~/.aliases as a line in your config. This separates your aliases from other shell configuration (PATH exports, functions, plugin settings) and makes the setup cleaner. Use alias with no arguments in the terminal to list all currently active aliases - useful for auditing what''s set and diagnosing command conflicts.

Frequently Asked Questions

Q: Do aliases work in all Mac terminal applications? A: Aliases defined in ~/.zshrc work in any terminal application that launches a login shell - Terminal, iTerm2, and VS Code''s integrated terminal all respect them by default.

Q: What is the difference between an alias and a shell function? A: Aliases replace a command string with another string. Shell functions can accept arguments and contain logic. For simple command replacements, aliases are sufficient; for parameterised or multi-step workflows, use a shell function instead.

Q: Why does my alias not work after restarting Terminal? A: The alias may have been added to ~/.bash_profile instead of ~/.zshrc, or the source command was not run. Confirm the alias is in ~/.zshrc and that your terminal is using Zsh (the Mac default since Catalina) with echo $SHELL.