Set Environment Variable
2 min readMar 6, 2024
The macOS shell configuration is crucial for setting up the environment variables and paths necessary for various commands and applications to function correctly. Here’s a step-by-step guide on how to configure the shell environment, specifically focusing on the zsh shell:
- Open Terminal: Launch Terminal on your macOS. You can find it in the “Utilities” folder within the “Applications” directory, or simply search for it using Spotlight.
- Edit the .zshrc File: — Type
vi ~/.zshrcand press Enter. This will open the .zshrc file in the Vi text editor. - PressIorInsertto enter insert mode. This allows you to make changes to the file. - Add or modify the paths as needed. For example, to include multiple paths in your PATH variable, you can use:export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/manzsoftech/.zshrc- PressEscto exit insert mode. - Type:wqand press Enter to save the changes and exit Vi. - Verify Environment Variables: — To see all environment variables, run
exportcommand. - Set Java JDK Path: — If you need to set the Java JDK path, you can use:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home- After running this command, you'll need to reload the profile:source ~/.zshrc - Change Shell (Optional): — If you want to change your shell to zsh, run:
chsh -s /bin/zsh- To revert back to bash, run:chsh -s /bin/bash - Edit .zsh_profile (Optional): — If you prefer using nano, run:
nano ~/.zsh_profile- If you prefer using Vim, run:vim ~/.zsh_profileThese steps should help you configure your macOS shell environment effectively. Remember to be cautious when editing configuration files to avoid breaking your system. Always make backups or document changes for reference.
Get Manzsoftech’s stories in your inbox
Join Medium for free to get updates from this writer.





