7

I want to create a bash alias on OS X, because I need to type on a really large command.

I've found some answers about the same issue on ubuntu, like this one, but they mention the ~/.bashrc file, which doesn't exist (at least by default) on OS X.

  • Is very common to find answers asking you to put the alias in the .bashrc, which you normally won't find in your OS X home directory. And I didn't find any answer stating this difference here in AskDifferent. That was the reasoning for posting this question. – Rafael Eyng Apr 8 '15 at 19:36
  • 2
    A simple search using Google leads to this page now. – Pavel Vlasov Oct 24 '15 at 13:40
9

I've found that I can do this by editing the .bash_profile file.

Just added:

alias my_alias='cd /my/really/long/long/path

to .bash_profile, and after reopening bash my alias command worked just fine.

  • 1
    Great, I was looking for this ! – Vasikos Sep 29 '16 at 15:25
  • Alternatively, run source ~/.bash_profile in the same terminal window to apply the changes without having to close the window. – anaik Mar 1 at 20:26
1
  1. nano ~/.bash_profile
  2. alias my_alias= 'ssh username@xxxx.xxx.xx.x'
  3. ctrl + x , then press y and enter to save.
  4. Don't forget to reload the file with:

    source ~/.bash_profileor . ~/.bash_profile

  5. Then test the alias.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .