You must have noticed that as soon as you exit your Mac Terminal, the environment variable such as $PATH is not available. The $PATH was available until the Terminal session was active, but soon as it was terminated, we do not have access to the variable. In order to set the $PATH variable permanently, you would need to set it in the .zshrc file (Z-Shell resource file).
What is .zshrc file?
.zshrc is a Zsh shell resource file. This file runs whenever you start zsh shell. So all the commands and scripts you write in this file are executed as soon as you launch the terminal. So if you want to set paths and other variables that you need for day-to-day programming or executions, it's always better to add them to this file.
How to add $PATH in .zshrc file?
- Open Terminal,
- Make sure you are on Zsh Shell, if not type zsh and hit enter,
- Now type nano ~/.zshrc
- Now add your $PATH variable details: Example: export PATH="$PATH:/opt/homebrew/bin/"
- Press Control + X, followed by Y to save the file, press enter to exit Nano,
- Now type command source ~/.zshrc to apply changes.
Now even when you close your terminal and open it or switch between prompts, the Zsh shell will always have your $PATH variable set and it will not get lost.
Have Questions? Post them here!
- How to list all users in Mac Terminal
- Docker Desktop needs privileged access macOS
- Mac: How to show count of files and folders in Finder
- How to Change Background Color TextEdit on Mac
- How to adjust MacBook Desktop icons size
- Test internet speed using macOS Terminal command
- How to change the default font and text size in Microsoft Excel for Mac
- How to install Java on macOS [Big Sur]
- How to come out of dquote prompt in Terminal - macOS/Linux
- How to Increase MacBook Trackpad Cursor Speed on macOS Ventura/Sonoma
- Fix: Microsoft Excel Quit Unexpectedly on Mac
- How to Adjust macOS System Font Size
- How to Quit Applications on Mac Using Terminal
- How to check zsh installed version using terminal
- Two Ways to Extract rar (*.rar) files on Mac
- How to Right Click on Mac Desktop?
- How to Add Brew to PATH M1/M2 Mac
- How to search (find) in macOS Terminal Console Text
- macOS 13 Ventura - The New About this Mac Window
- TextEdit Get the count of lines in a file
- How to run .sh file in Mac Terminal
- Google Search Hot Trends Screensaver for Mac OS X
- Check Reboot History Mac
- [Solution] Mac Update Stuck Preparing macOS Ventura 13.0 About 30 minutes remaining
- Display Safari URL address link on hover
- Fix - Error:Invalid Gradle JDK configuration found (Android Studio) - Gradle
- Split a String in Java with Examples - Java
- Android Studio : Connection Error : Failed to download patch file - Android-Studio
- Set Title to Android AlertDialog - Android
- Force Gradle to use specific Java JDK Version - Gradle
- How to do a Reverse Image Search Using Google Tools - Google
- How to find the Length of ArrayList in Java - Java
- Get MD5 Hash as Checksum of a String in Python - Python