Skip to content

Instantly share code, notes, and snippets.

@teisman
Last active December 16, 2015 15:59
Show Gist options
  • Save teisman/5459813 to your computer and use it in GitHub Desktop.
Save teisman/5459813 to your computer and use it in GitHub Desktop.

##bashrc | bash_profile

Configuring your bash shell, you often want to specify environment variables, set the search path, and do other configurations. The question arises which files need to be configured in order to do so. A unix shell can run in two modes; as a login shell or as a non-login shell. In case of bash - a Bourne type shell - the login and the non-login variants call their own configuration files, which can be found in ~/.bash_profile and ~/.bashrc respectively. The seperation between login and non-login shells makes sense. When a user first logs in to a system (for example via ssh), the user may want to set specific parameters such as which type of terminal is running, or may want to display specific login messages. To avoid doing the same (potentially relatively expensive) initialization, later invocations of the shell will normally open the non-login shell, which can be configured to run with a light initialization.

###Solution When you want to load a PATH variables under all circumstances, you could define the variables in the ~/.bashrc file, and tell ~/.bash_profile to load the the bashrc config as follows:

if [ -f ~/.bashrc ]; then
  source ~/.bashrc
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment