Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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