So I have written a simple bash script to run a program called "cmatrix" everytime a new terminal window is opened.
I have changed the permissions on the file so it is r-x for everyone, and verified that it will run exactly how I want it to when called, but now I don't know where to put the script so that it runs on each new bash terminal launch. I know that if I want it to run on startup I would place it in usr/local/bin, but I only want it to run when I open a new terminal window.
Very very simple:
cmatrix -bs -C cyan
Any and all help is appreciated!
Thanks
1 Answer 1
Assuming bash is your default shell, any bash command you put into your ~/.bashrc file will be executed when opening a new terminal window (interactive shell). For example, putting echo "Hello" at the end of your ~/.bashrc file will popup this message)
For your script to be executed on opening a new bash window, you can just:
- Move your script to
/usr/local/bin/ - Call your script from your
~/.bashrcfile
Notice:
You don't absolutely need to move your script to
/usr/local/bin/, but it's convenient as it doesn't require the extra step to modify your path, or to call your script with its absolute path.To actually call your script from your
~/.bashrc, just add your script name at the end of the file:my_cool_script.shIf your script is a single line long, you can actually put that line in your
~/.bashrcinstead of your script name, in your case:cmatrix -bs -C cyan
-
@KamilMaciorowski Thanks for the polished details. Answer edited.Yoric– Yoric2019年01月23日 10:55:22 +00:00Commented Jan 23, 2019 at 10:55
You must log in to answer this question.
Explore related questions
See similar questions with these tags.
/usr/local/binhas nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right).