0

But, they still work after source .bash_aliases.

I have the following lines in my .bashrc:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

This is supposed to be equivalent to typing source .bash_aliases, isn't it?

Benjamin
  • 202
  • Yeah, looks like it should work. Do you have to source the file explicitly every time you start a shell? – Zanna Mar 03 '17 at 21:36
  • Yeah, exactly.

    I do have my .bash_aliases stored in my Dropbox, with ~/.bash_aliases as a symlink to ~/Dropbox/.bash_aliases, but that shouldn't matter, right?

    – Benjamin Mar 03 '17 at 22:04

3 Answers3

1

I figured it out; it was caused by my having created a .bash_profile in following a tutorial to set up a GPG key. In the presence of a .bash_profile file, the entire .bashrc file is ignored.

Benjamin
  • 202
  • 1
    It's not that the .bash_profile file causes the .bashrc to be ignored. The situations in which bash sources the two are different. However, .bash_profile takes precedence over .profile, which is used by default on Ubuntu, and the default Ubuntu version sources .bashrc: http://askubuntu.com/questions/432508/why-does-ubuntus-default-profile-source-bashrc, hence the overall effect. – muru Mar 10 '17 at 17:28
0

Try to place the same alias in bash_profile file also. And restart your terminal

Jay
  • 101
  • 2
0

From man [:

   -f FILE
          FILE exists and is a regular file

Since you made .bash_aliases a link, this test is failing. Either make it a regular file and not a soft link, or change this test.