Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

The right file for environment variables such as PATH is not ~/.bashrc but ~/.profile. .bashrc is a configuration file for interactive shells; .profile is the session startup script. See Is there a ".bashrc" equivalent file read by all shells?Is there a ".bashrc" equivalent file read by all shells?.

Bash is a bit peculiar with its startup files: in login shells, it reads ~/.bash_profile if it exists and ~/.profile otherwise. In interactive non-login shells, it reads ~/.bashrc. There's no reason not to load interactive settings in interactive login shells, and there are many setups where the session start shell is not invoked as a login shell but ~/.profile is read explicitly. So make your ~/.bash_profile contain just these two lines:

. ~/.profile
case $- in *i*) . ~/.bashrc;; esac

If you had things in ~/.bash_profile, move them to ~/.profile if they are things like environment variable settings, and to ~/.bashrc if they are interactive shell configuration such as aliases and key bindings. Put all your PATH manipulation in ~/.profile.

The right file for environment variables such as PATH is not ~/.bashrc but ~/.profile. .bashrc is a configuration file for interactive shells; .profile is the session startup script. See Is there a ".bashrc" equivalent file read by all shells?.

Bash is a bit peculiar with its startup files: in login shells, it reads ~/.bash_profile if it exists and ~/.profile otherwise. In interactive non-login shells, it reads ~/.bashrc. There's no reason not to load interactive settings in interactive login shells, and there are many setups where the session start shell is not invoked as a login shell but ~/.profile is read explicitly. So make your ~/.bash_profile contain just these two lines:

. ~/.profile
case $- in *i*) . ~/.bashrc;; esac

If you had things in ~/.bash_profile, move them to ~/.profile if they are things like environment variable settings, and to ~/.bashrc if they are interactive shell configuration such as aliases and key bindings. Put all your PATH manipulation in ~/.profile.

The right file for environment variables such as PATH is not ~/.bashrc but ~/.profile. .bashrc is a configuration file for interactive shells; .profile is the session startup script. See Is there a ".bashrc" equivalent file read by all shells?.

Bash is a bit peculiar with its startup files: in login shells, it reads ~/.bash_profile if it exists and ~/.profile otherwise. In interactive non-login shells, it reads ~/.bashrc. There's no reason not to load interactive settings in interactive login shells, and there are many setups where the session start shell is not invoked as a login shell but ~/.profile is read explicitly. So make your ~/.bash_profile contain just these two lines:

. ~/.profile
case $- in *i*) . ~/.bashrc;; esac

If you had things in ~/.bash_profile, move them to ~/.profile if they are things like environment variable settings, and to ~/.bashrc if they are interactive shell configuration such as aliases and key bindings. Put all your PATH manipulation in ~/.profile.

Source Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

The right file for environment variables such as PATH is not ~/.bashrc but ~/.profile. .bashrc is a configuration file for interactive shells; .profile is the session startup script. See Is there a ".bashrc" equivalent file read by all shells?.

Bash is a bit peculiar with its startup files: in login shells, it reads ~/.bash_profile if it exists and ~/.profile otherwise. In interactive non-login shells, it reads ~/.bashrc. There's no reason not to load interactive settings in interactive login shells, and there are many setups where the session start shell is not invoked as a login shell but ~/.profile is read explicitly. So make your ~/.bash_profile contain just these two lines:

. ~/.profile
case $- in *i*) . ~/.bashrc;; esac

If you had things in ~/.bash_profile, move them to ~/.profile if they are things like environment variable settings, and to ~/.bashrc if they are interactive shell configuration such as aliases and key bindings. Put all your PATH manipulation in ~/.profile.