Reputation: 101
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
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