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 connect AirPods to Mac
- Display Safari URL address link on hover
- Mac turn dark mode on or off using terminal command
- Docker Desktop needs privileged access macOS
- How to install Java on macOS [Big Sur]
- How to start/boot macOS in safe mode - Big Sur 11.0, Catalina 10.15, or Mojave 10.14
- Find Mac version using terminal command
- How to fix command not found brew (bash, zsh) on macOS Terminal
- How to change default macOS Terminal Window size
- How to make EditText text to uppercase or lowercase on macOS
- Disable Startup Sound on macOS
- How to switch from bash to zsh shell in macOS Terminal
- How to make macOS Terminal window Transparent (or Opaque)
- Remove Now Playing icon from macOS Big Sur Menu Bar
- Test internet speed using macOS Terminal command
- How to change macOS Safari default language
- Encode or Decode Base64 String using Mac Terminal Command
- Safari - Get HTTP Request Response Headers
- How to open terminal on Mac to run commands
- How to install homebrew (brew) on M1 Mac
- How to display directory tree in Mac Terminal
- How to Change Mouse Wheel Scroll Direction on Mac
- MacoOS - xyz is an app downloaded from the internet. Are you sure you want to open it? Alert
- The default interactive shell is now zsh. [macOS]
- Change Terminal Cursor Type in Mac (MacOS Shell)
- 12 August - International Youth Day celebrated worldwide - News
- Your JBoss Application Server 7 is running However you have not yet added any users to be able to access the admin console - Java
- airbnb website and mobile App is down worldwide - clear browser cache or reinstall app to fix error - News
- Mac (macos) startup keyboard boot sequence combinations - MacOS
- Test internet speed using macOS Terminal command - MacOS
- zsh: command not found [fix] macOS - zsh
- How to install Postman natively on a Mac - HowTos
- Add blank lines after each lines using Notepad++ text editor - NotepadPlusPlus