See how differently shell script is executed using
source command executes the provided script (executable permission is not mandatory) in the current shell environment, while
./ executes the provided executable script in a new shell.
sourcecommand do have a synonym
To make it more clear, have a look at the following script, which sets the alias, using a shell script file named,
3. Two options
Now we have two choices to execute this script. But with only one option, the desired alias for your current shell can be created among these two options.
3.1. Option 1
Make script executable first.
no alias for myproject
Whoops!, alias is gone with the new shell.
Now, let’s go with the second option.
3.2. Option 2
No need to make script executable while using
Yeah, alias is set now.