Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I added this line into my ~/.bashrc file.

alias myserver='ssh davidfaux@davidfaux.com'

However, when I open terminal and run myserver, terminal complains that

-bash: myserver: command not found

When I source my .bashrc file, however, (. .bashrc), the alias works.

Nonetheless, I do not want to source the file every time I open terminal for the alias to work. How do I make that happen?

share|improve this question
3  
This comment explains the reason for this. That question tells you how to fix it. – ughoavgfhw Mar 4 '12 at 19:35
Thanks a lot! I did not know that starting the shell executes those files in order. Indeed, adding . .bashrc into .bash_profile works. – David Faux Mar 4 '12 at 19:43
@ughoavgfhw can/should you change your comment to an answer? That way it can be marked as an answer. – soxman Mar 5 '12 at 14:14

1 Answer

up vote 3 down vote accepted

As noted...

By default, Terminal starts the shell via /usr/bin/login, which makes the shell a login shell. On every platform (not just Mac OS X) bash does not use .bashrc for login shells (only /etc/profile and the first of .bash_profile, .bash_login, .profile that exists and is readable). This is why “put source ~/.bashrc in your .bash_profile” is standard advice. – Chris Johnsen

For More information see the manual page for bash. Then look under the INVOCATION section.

man bash
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.