
bash_profile by adding the following to new lines of the file:Įxport JAVA_HOME=$(/usr/libexec/java_home)Įxport JRE_HOME=$(/usr/libexec/java_home)Īssuming we’re now finished, save changes made to. Let’s take an example and say we’re going to set the JAVA_HOME and JRE_HOME environmental variables within. bash_profile file, just be sure to add new variables to a new blank line by using the arrow keys and the return key as necessary. You can add environmental variables and shell variables onto new lines, if there is already data within the. bash_profile within the nano text editor: bash_profile with nano – you can use vi, emacs, or another text editor if you’d like, but we’ll cover nano for it’s simplicity. We’re going to assume you’re still using the OS X default bash shell, thus we’ll add new environment variables by modifying. If you changed your shell or you aren’t sure what shell you’re using, you can always check by issuing the echo $SHELL command, which will display which shell is in use. bash_profile, for an active user account the path to that file is locate at:

MAC OS X UNINSTALL TYPORA MAC OS X
Thus you can add zsh environmental variables by modifying that file with nano, vim, etc, or by using echo like so:Įcho 'export ENV_VAR=example' > ~/.zshenvĮcho 'JAVA_HOME=$(/usr/libexec/java_home)' > ~/.zshenv Setting Environmental Variables in Mac OS X Command Line with bashīecause the Mac defaults to using bash shell, you can set environmental variables in the user directories. The zsh shell sets environmental variables through the zshenv file, located in the users home directory at: Setting Environmental variables in macOS Command Line with zsh The output of these commands can be lengthy so you may wish to pipe the output through the less or more commands. If you want to see a complete list of shell variables, the ‘set’ command can be issued as well: To list environmental variables in zsh, use the following command:

To quickly get a list of environmental variables, you can use the following command with bash: We’ll cover this for both bash and zsh shells.ĭisplaying Current Environment & Shell Variables in bash on Mac OS X
MAC OS X UNINSTALL TYPORA HOW TO
Let’s walk through how to list environment and shell variables, and then how to set and add new environment variables at the command line of Mac OS X.
