In general, please remember to include your Operating System, the correct answer is often system dependent. Remember that bash is used by default on most Linuxes, OS X and many UNIXes.
Anyway, in your case the OS should be irrelevant, so what you need to do is set the PROMPT_COMMAND variable:
Bash provides an environment variable called PROMPT_COMMAND. The contents of this variable are executed as a regular Bash command just before Bash displays a prompt.
So, since the command you want to run is sourcing ~/.bashrc
, add this line to your ~/.bashrc
(the .
is just an alias to source
):
PROMPT_COMMAND='source ~/.bashrc'
Now, every time Bash displays a prompt, it will first re-read ~/.bashrc
. To get your open terminals (as long as they've been opened after you set PROMPT_COMMAND
) to update just run any command or simply hit Enter.
WARNING: Depending on the complexity of your ~/.bashrc
, this could add a noticeable lag since any commands in the file will be executed repeatedly.