Fiery panda
Fiery panda

Reputation: 101

Sourcing the same shell script file everytime

I just had a quick question regarding sourcing files in shell script.

I have created a shell script file that has a function which I can execute. However, everytime I restart my terminal and run the command in my shell I have to run source ~/path/to/shell/file everytime before running my function.

Is there any permanent fix for this?

Thank you!

Upvotes: 2

Views: 715

Answers (1)

Mark Reed
Mark Reed

Reputation: 95267

This is what the shell startup files are for. If you're using bash, any commands you place in the file .bashrc in your home directory ($HOME/.bashrc) will be executed every time you start a new shell (the name is short for "bash run commands"). So either copy the file with your function definition into the .bashrc or just add the source command to it, and you should be good to go.

Upvotes: 4

Related Questions