Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if .bash_profile usually source .bashrc any way, why not just use .bashrc?

it seems that we will put

source ~/.bashrc

in our .bash_profile anyway. So why not just use one file, say .bashrc ?

like image 947
nonopolarity Avatar asked May 26 '09 01:05

nonopolarity


2 Answers

Because there may be things you only want to do once per login (so in .bash_profile) rather than every time an xterm or the like opens (as per .bashrc), for example asking the user for a passphrase to decrypt and load SSH keys into an ssh agent, etc etc.

like image 186
Alex Martelli Avatar answered Nov 16 '22 04:11

Alex Martelli


You can put some things in .bash_profile that are not appropriate for a shell instance that is not a terminal. For example, if you ran an external command from your editor through the shell - the shell instance would source .bashrc but not .bash_profile. For example, I might put alias ls=ls -F in my profile, but you wouldn't want that alias applied for just any instance of the shell, just ones you would interact with.

like image 41
1800 INFORMATION Avatar answered Nov 16 '22 04:11

1800 INFORMATION