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!
- Cut, Copy and Paste keyboard commands on mac
- [macOS] Change homepage Macbook Safari Browser
- This operation couldnt be completed. Unable to locate a Java Runtime. [macOS]
- Permanently set $PATH variable in Mac Zsh shell
- macOS Big Sur compatible Macs List
- How to make EditText text to uppercase or lowercase on macOS
- How to make macOS Terminal window Transparent (or Opaque)
- Shutdown Mac Terminal Command
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- Set Python 3.8 as a default python version on macOS
- Create Custom Android AlertDialog - Android
- Copy Text to Android Clipboard Programmatically ClipboardManager - Android
- Facebook Down Will Be Back Soon - Facebook
- How to check installed Eclipse version 32-bit or 64-bit - Eclipse
- How to create an Autocomplete Android EditText Example - Android
- How to display Toast on Button Click : Android - Android
- Two Buttons next to each other in Android Layout - Android
- JSON Datatypes : Tutorial - Json-Tutorial
- Eclipse : Workspace was written with an older version of the product and will be updated - Eclipse
- Android Error Unexpected cast to Button: layout tag was FrameLayout - Android
- [Solved] SharePoint System.IO.FileNotFoundException was unhandled - SharePoint
- Fibonacci series from 1 to 500 table - Html
- The author stylesheet specified in tag script is too long - document contains 21759 bytes whereas the limit is 10000 bytes - Html
- Facebook Graph API Unavailable - Facebook