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!


  • What do you mean by "terminal window"? A window from a (specific?) terminal emulator? Any tty? Any interactive Bash session? Please edit the question and clarify. (Side note: I think /usr/local/bin has nothing to do with running anything on startup. Not really relevant to your question though, even if I'm right). Jan 23, 2019 at 9:27

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:

  1. Move your script to /usr/local/bin/
  2. Call your script from your ~/.bashrc file


  1. 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.

  2. To actually call your script from your ~/.bashrc, just add your script name at the end of the file:


  3. If your script is a single line long, you can actually put that line in your ~/.bashrc instead of your script name, in your case:

    cmatrix -bs -C cyan

  • @KamilMaciorowski Thanks for the polished details. Answer edited.
    – Yoric
    Jan 23, 2019 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.