Zsh Configuration Tutorial: Customize Your Terminal with .zshrc, Aliases & Prompts
Video: Zsh Configuration Tutorial: Customize Your Terminal with .zshrc, Aliases & Prompts by Taught by Celeste AI - AI Coding Coach
Watch full page →Zsh Configuration Tutorial: Customize Your Terminal with .zshrc, Aliases & Prompts
Customizing your Zsh shell can greatly improve your terminal workflow by making commands shorter and your prompt more informative. This guide covers editing the .zshrc file to create aliases, set environment variables, and personalize your prompt for a more efficient and visually appealing terminal experience.
Code
# Open or create your .zshrc file in your home directory
# Example aliases for frequently used commands
alias ll='ls -la' # List all files with detailed info
alias gs='git status' # Shortcut for git status
alias c='clear' # Clear the terminal screen
# Setting environment variables
# Local variable (only current shell)
MY_VAR="local_value"
# Exported variable (available to child processes)
export PATH="$HOME/bin:$PATH" # Add custom bin directory to PATH
export MY_VAR="exported_value"
# Customize your prompt with colors and info
# %n = username, %m = hostname, %~ = current directory, %# = prompt symbol
# %F{color} starts color, %f ends color
PROMPT='%F{green}%n%f@%F{blue}%m%f %F{yellow}%~%f %# '
# Apply changes without restarting terminal
source ~/.zshrc
Key Points
- The
.zshrcfile is your shell’s startup script where you store customizations. - Aliases save time by creating shortcuts for long or frequently used commands.
- Use
exportto make environment variables available to child processes and scripts. - The
PROMPTvariable controls your terminal prompt’s appearance using special percent codes. - Run
source ~/.zshrcto reload your configuration instantly after edits.