Is there a way to always run the same file in TextMate, when working on a Python project? I always press ⌘+R when editing a random file, forgetting to switch back to the tab containing the main of this project. There's got to be a way to do that; clicking tabs is really a speed-bump in that scenario.
Yes it is possible and there are several possibilities to achieve that. An easy fix would be to write a command which invokes python on the main file, i.e.
as a command bound to Command + R. Better commands would be
However, you will loose the nice looking output the default command provides. Therefore you have another option: Set the instance variable $TM_PROJECT_MASTER to point to your main file. You can either set this variable absolute or relative to $TM_PROJECT_PATH. A relative path may be advisable of course. To do so, you may either set $TM_PROJECT_MASTER as a static environment variable, which can be done as follows
If the location of your main file changes from project to project, this setting doesn't help. However, you can set project dependent shell variables, which would be the solution in such cases:
This should help. Have fun!
PS: See https://github.com/textmate/python.tmbundle/commit/c3e38e318c5e80b8fdd78730d65f1a7dee5aa911 if you look for an explanation, why setting $TM_PROJECT_MASTER helps.