
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add New Entry to PATH Variable in Zsh on Mac OS
By default, we don’t have the .zshrc file present in macOS Catalina, and we need to create it. In order to create the .zshrc file, we can follow the steps shown below −
Open Terminal
Type touch ~/.zshrc to create the file.
Hit Return
We can also open the .zshrc file in the terminal from any directory by just typing the command shown below
Example
vi ~/.zshrc
Output
immukul@192 linux-questions-code % cat ~/.zshrc export GOPATH=/Users/immukul/go_projects export NDHOME=/Users/immukul/Downloads export GOTRACEBACK=all export GOROOT=/usr/local/go export LC_CTYPE=C export PATH=/home/Systems export LANG=C
It should be noted that the output may vary from machine to machine.
To add an entry to the PATH variable present inside the we can write the following command to the terminal, and we don’t even have to open the zshrc file to do that.
Command
echo -n 'export PATH=~/some/path:$PATH' >> ~/.zshrc
Output
immukul@192 linux-questions-code % cat ~/.zshrc export GOPATH=/Users/immukul/go_projects export NDHOME=/Users/immukul/Downloads export GOTRACEBACK=all export GOROOT=/usr/local/go export LC_CTYPE=C export PATH=/home/Systems:/some/path export LANG=C
Another approach is to open the zshrc file and then insert the export command manually.
Command
export PATH=/home/bin:$PATH
Output
immukul@192 linux-questions-code % cat ~/.zshrc export GOPATH=/Users/immukul/go_projects export NDHOME=/Users/immukul/Downloads export GOTRACEBACK=all export GOROOT=/usr/local/go export LC_CTYPE=C export PATH=/home/Systems:/some/path:/home/bin export LANG=C
It is recommended to source the file once you are done to make the changes available to all the terminals.