Manage Environment PATH in macOS 13 Shell Config
Managing environment paths on macOS 13 (Ventura) allows the operating
system to locate and execute command-line utilities without requiring
their absolute paths. Because macOS 13 uses Zsh as the default login
shell, environment variables such as PATH are primarily
handled through Zsh configuration files like .zshrc and
.zprofile. This guide covers how to view your current path,
modify the configuration files correctly, and apply your changes
immediately.
Understanding Zsh Configuration Files
macOS 13 relies on the Zsh shell by default. To set user-specific environment variables, you should modify one of two hidden files located in your home directory:
~/.zshrc: Loaded for every new interactive shell session (recommended for most user configurations, aliases, and terminal utilities).~/.zprofile: Loaded once at login (ideal for system-wide environmental variables and performance-sensitive configurations).
Step 1: Check Your Current PATH
To view the directories currently configured in your environment, open Terminal and run:
echo $PATHDirectories are listed in order of priority, separated by colons
(:).
Step 2: Edit the Configuration File
Open your ~/.zshrc file in a terminal text editor such
as nano:
nano ~/.zshrcIf the file does not already exist, this command will create it automatically.
Step 3: Add Your Custom Directory to PATH
To append or prepend a directory to your PATH, use the
export command. Add the following line at the end of the
file:
export PATH="/your/custom/path:$PATH"- Placing
/your/custom/pathbefore$PATHensures your custom directory takes precedence over system defaults. - Placing it after
(
export PATH="$PATH:/your/custom/path") sets it as a fallback.
Replace /your/custom/path with the absolute path to your
binary folder (e.g., /opt/homebrew/bin or
$HOME/.local/bin).
Step 4: Save and Reload the Configuration
- Press
Ctrl + OandEnterto save changes innano. - Press
Ctrl + Xto exit the editor. - Apply the changes immediately to your current session by running:
source ~/.zshrcVerify that the new directory is present by running
echo $PATH again.
Alternative:
System-Wide Paths via /etc/paths.d
For system-wide paths applicable to all users, macOS provides the
/etc/paths file and the /etc/paths.d
directory. You can create a new file containing your path inside
/etc/paths.d:
sudo sh -c 'echo "/your/custom/path" > /etc/paths.d/myapp'This method cleanly separates application paths without requiring manual edits to user shell scripts. Restart your terminal session for system-wide changes to take effect.