Every time I add a new alias in my .bash_profile file, I found that I must do the command . .bash_profile
in my terminal to make it work.
Why does the alias not work automatically?
Every time I add a new alias in my .bash_profile file, I found that I must do the command . .bash_profile
in my terminal to make it work.
Why does the alias not work automatically?
First of all, you should put the aliases in ~/.bashrc
and not in ~/.bash_profile
.
Next the explanation: the aliases are read and make available only when the file that contain them is read. So the requirement to source that file.
~/.bashrc
? They seem to work both ways. Also, what is sourcing a file? – David Faux Mar 04 '12 at 18:27~/bashrc
is read for interactive shells, and aliases are only useful in interactive shells. "Sourcing" refers to read and execute a script in the current shell (as opposed to a subshell). To source a script you use the dot.
or thesource
builtin command. – enzotib Mar 04 '12 at 18:32