This guide will help you set up and effectively use the Terminal application on macOS with Oh My Zsh for an improved command-line experience.
Terminal
and press EnterCommand | Description | Example |
---|---|---|
pwd |
Print working directory (current location) | pwd |
ls |
List files and directories | ls -la (show all files with details) |
cd |
Change directory | cd Documents or cd .. (go up one level) |
mkdir |
Create a new directory | mkdir projects |
rm |
Remove files | rm filename.txt |
rmdir |
Remove empty directory | rmdir emptydir |
touch |
Create an empty file | touch newfile.txt |
cp |
Copy files | cp file.txt Documents/ |
mv |
Move or rename files | mv file.txt newname.txt |
cat |
Display file contents | cat file.txt |
clear |
Clear terminal screen | clear |
history |
Show command history | history |
Oh My Zsh is an open-source framework for managing your Zsh configuration that comes with helpful functions, plugins, themes, and more.
Make sure you have Zsh installed (default shell in macOS Catalina and newer):
zsh --version
Install Homebrew if you don’t have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Oh My Zsh using curl:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
After installation, your terminal will automatically restart with Oh My Zsh active
Edit your configuration file:
nano ~/.zshrc
Change the theme by modifying the ZSH_THEME
line:
# Popular themes: robbyrussell, agnoster, avit, bira
ZSH_THEME="robbyrussell"
Add plugins by modifying the plugins
line:
plugins=(git vscode brew macos)
Save changes and apply them:
source ~/.zshrc
Add custom shortcuts by editing your ~/.zshrc
file:
# Example aliases
alias gs="git status"
alias gc="git commit -m"
alias ll="ls -la"
To add permanent environment variables:
Edit your ~/.zshrc
file:
nano ~/.zshrc
Add export statements:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$PATH:$JAVA_HOME/bin
Apply changes:
source ~/.zshrc
Last updated: May 4, 2025