1

This question already has an answer here:

OS X 10.11.2 El Capitan

I want to create some alias, so I go to ~/ folder and there is no .bash_profile or .bashrc.

ls -a ~/

I have been looking for some info and I learn that .bash_profile is only read when bash launch an interactive login shell (default type of terminal in OS X) and .bashrc is only read when bash launch an interactive non-login shell. But I don't find how to create .bash_profile and .bashrc for my user. How can I do it?

After @klanomath answer:

enter image description here

marked as duplicate by grg osx Dec 14 '15 at 19:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You may want to create a .bashrc that contains:- [ -r ~/.bash_profile ] && source ~/.bash_profile so that all shells will share the same settings. – Milliways Dec 12 '15 at 3:53
4

Open Terminal and enter:

touch ~/.bash_profile
touch ~/.bashrc

To edit the file(s) use:

nano ~/.bash_profile
nano ~/.bashrc

Instead of nano you can use any decent text editor (e.g. BBEdit, TextWrangler).

To immediately enable any changes in the file .bash_profile use source:

source ~/.bash_profile
  • I already try that but didn't work :( Please, look the new photo that I attach to the question. Thanks for the help. – user161254 Dec 12 '15 at 0:17
  • I try source ~/.bash_profile …didn't work. – user161254 Dec 12 '15 at 0:23
  • @raaowx the correct expression is alias lsa='ls -a | egrep "\.[a-zA-Z0-9]"'instead of alias lsa='ls -a | egrep '\.[a-zA-Z0-9]'! The inner ' are wrong and you are missing one finishing ' – klanomath Dec 12 '15 at 0:30