How to reload .bash_profile from the command line?
Simply type source ~/.bash_profile
.
Alternatively, if you like saving keystrokes, you can type . ~/.bash_profile
.
Simply type:
. ~/.bash_profile
However, if you want to source it to run automatically when terminal starts instead of running it every time you open terminal, you might add . ~/.bash_profile
to ~/.bashrc
file.
Note:
When you open a terminal, the terminal starts bash in (non-login) interactive mode, which means it will source ~/.bashrc
.
~/.bash_profile
is only sourced by bash when started in interactive login mode. That is typically only when you login at the console (Ctrl+Alt+F1..F6), or connecting via ssh
.
If you don't mind losing the history of your current shell terminal, you could also do
bash -l
That would fork your shell and open up another child process of bash. The -l
parameter tells Bash to run as a login shell. This is required, because .bash_profile will not run as a non-login shell. For more information about this, read here.
If you want to completely replace the current shell, you can also do:
exec bash -l
The above will not fork your current shell, but replace it completely, so when you type exit
it will completely terminate, rather than dropping you to the previous shell.
. ~/.bash_profile
Just make sure you don't have any dependencies on the current state in there.