Creating permanent executable aliases

Yarin picture Yarin · Feb 28, 2011 · Viewed 47.8k times · Source

I have MySQL installed (MAMP, Mac OS X) but need to call it by the full path each time I access it from the shell. I created an alias: alias mysql='/Applications/MAMP/Library/Bin/mysql, but this only lasts as long as my terminal/Bash session.

What is an effective way for establishing permanent aliases that will work across users? (I need to be able to execute commands from PHP). Should I set up aliases in the Bash start up script (how is that done?), or is it better to edit the sudoers file? (Could use an example of that as well..)

Thanks--

EDIT- Based on answer:

I just tried creating a ~/.bashrc and wrote the following:

alias mysql='/Applications/MAMP/Library/bin/mysql'

But this doesn't seem to have any effect. Is there a special syntax for this file?

Answer

Dennis Williamson picture Dennis Williamson · Feb 28, 2011

Add the command to your ~/.bashrc file.

To make it available to all users, add it to /etc/profile.