Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"source" command on mac

I have a .bashrc file on Mac OS in which I set some aliases. After I make it and I type source .bashrc, the aliases work perfectly. However if open another shell, my shortcut command will not be recognized and I need to do source .bashrc again. How can it make it once and for all?

like image 785
user1849043 Avatar asked Jan 18 '14 23:01

user1849043


People also ask

What is the source command?

source is a shell built-in command which is used to read and execute the content of a file(generally set of commands), passed as an argument in the current shell script. The command after taking the content of the specified files passes it to the TCL interpreter as a text script which then gets executed.

How do I use source command in Terminal?

Source Command Syntax Where: [filename] : The name or path to the file you want the source command to execute. [arguments] : Any arguments you provide become positional parameters when the file is executed.


2 Answers

I encounter the same problem and I solve it. The macos have shift the default shell from bash to zsh.

So I try to modify the ~/.bashrc and ~/.bash_profile and source that but just work to current Terminal.

The fact is you should modify the ~/.zshrc profile file.

Try it my friend!

like image 55
Pandy Avatar answered Oct 31 '22 02:10

Pandy


If you are on Mac and you want to source ~/.bash_profile automatically on when a terminal is opened

  1. Open Terminal
  2. Go to Preferences
  3. Go to Profiles
  4. Select then open shell
  5. Add this command source ~/.bash_profile in Run command enter image description here
like image 20
Umer Waqas CEO Fluttydev Avatar answered Oct 31 '22 03:10

Umer Waqas CEO Fluttydev