Say I have a python program called foo.py that prints a line of text. How can I auto run that program when I boot up the terminal? I know you can, but I can't find the documentation. Also no third party programs please, I'm not looking to make the program executable, just to have it run on the terminal start up.


You can put command to run the script in .bashrc file inside your home directory, this file is read every time you open non-login shell (Terminal, Iterm and their tabs).

python /path/to/foo.py

Don't forget to set the permissions for all to execute:

chmod a+x foo.py
  • Didn't need chmod a+x foo.py is that a problem? All I did was designate the directory in my .bashrc_profile? – Monte Carlo Jun 28 '13 at 18:07
  • It's not a problem - it depends how you call foo.py. If you use python foo.py you do not need to set the execute permissions. If you instead use simply foo.py, you do. – Scot Jun 28 '13 at 18:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .