I have a one-line
.bashrc file in my home directory:
alias countlines='find . -type f -print0 | xargs -0 cat | wc -l'
But it is not creating the alias. Why might that be?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
.bashrc can be used on both OS X and Linux. The former is loaded when the shell is a login shell; the latter when it is not. The real difference is that Linux runs a login shell when the user logs into a graphical session, and then, when you open a terminal application, those shells are non-login shells; whereas OS X does not run a shell upon graphical login, and when you run a shell from Terminal.app, that is a login shell.
If you want your aliases to work in both login and non-login shells (and you usually do), you should put them in .bashrc and source .bashrc in your .bash_profile, with a line like this:
[ -r ~/.bashrc ] && source ~/.bashrc
This applies to any system using bash.
On Mac OS X Yosemite, run the following command:
Then add the following line:
Now save and close
.profile, then open a new Terminal window or just run:
See also this answer. It worked on v10.10.3.