Sitemap
Manzsoftech

Manzsoftech

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:

    Get Manzsoftech’s stories in your inbox

    Join Medium for free to get updates from this writer.

  1. 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.
  2. Edit the .zshrc File: — Type vi ~/.zshrc and press Enter. This will open the .zshrc file in the Vi text editor. - Press I or Insert to 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 - Press Esc to exit insert mode. - Type :wq and press Enter to save the changes and exit Vi.
  3. Verify Environment Variables: — To see all environment variables, run export command.
  4. 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
  5. 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
  6. Edit .zsh_profile (Optional): — If you prefer using nano, run: nano ~/.zsh_profile - If you prefer using Vim, run: vim ~/.zsh_profile These 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.

--

--