Table of contents
.bash_profile is executed for login shells, while
.bashrc is executed for interactive non-login shells.
When you login (type username and password) via console, either sitting at the machine, or remotely via ssh:
.bash_profile is executed to configure your shell before the initial command prompt.
But, if you’ve already logged into your machine and open a new terminal window (xterm) then
.bashrc is executed before the window command prompt.
.bashrc is also run when you start a new bash instance by typing
/bin/bash in a terminal.
On OS X, Terminal by default runs a login shell every time, so this is a little different to most other systems, but you can configure that in the preferences.
zsh is extra cool functionality that can be added on your terminal. For zsh
Say we like to add type
mysql in terminal and
/firstname.lastname@example.org/bin/mysql should be executed. In this case we have to add the path to
.zshrc as you prefered one.
To do this in terminal type:
echo 'export PATH="/email@example.com/bin:$PATH"' >> ~/.bashrc# For ZSHecho 'export PATH="/firstname.lastname@example.org/bin:$PATH"' >> ~/.zshrc
To add environment variable the process is almost the same.
echo 'export NODE_OPTIONS="--max-old-space-size=16384"' >> ~/.bashrc# For ZSHecho 'export NODE_OPTIONS="--max-old-space-size=16384"' >> ~/.zshrc
You can simply restart the terminal to activate the new configuration. Otherwise run the following command to activate it instantly.
The question can be paraphased as:
How do I reload
.zshrc without logging out and back in?
source ~/.bashrcsource ~/.zshrc# or you can use the shorter version of the command:. ~/.bashrc. ~/.zshrc