0


I have added some aliases and functions to the .bash_profile but they are not available when I start a new Command Line Prompt. Neither they are available after a reboot. I need to execute a 'source ~/.bash_profile' each time. So, I have added into the .bashrc file the following:

if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
#Added source
source ~/.bash_profile

However now when I try to open a new shell, the window just pops up for a second and then closes. Any idea how to apply changes in .bash_profile immediately? Thanks

  • 5
    Why don't you add your aliases to .bashrc? That's the file that is sourced for interactive shells after all. – Kusalananda Feb 14 at 11:11
  • 4
    .bash_profile is meant to be executed while opening bash in interactive login-shell, not while opening terminal. You should make changes in .bashrc. – Prvt_Yadv Feb 14 at 11:14
  • 4
    Related (possibly a duplicate): What is the purpose of .bashrc and how does it work? – Kusalananda Feb 14 at 11:50
  • 1
    There seems to possibly be another issue here as well. You say that the terminal closes immediately? Is your .bash_profile sourcing .bashrc (creating a loop). In that case, just delete the sourcing that you added yourself in .bashrc. – Kusalananda Feb 14 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.