Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using TextMate 2.0-alpha.9427 on OS X 10.8.2. Since two days, when I run a script (Python or shell script), instead of the directory of the script itself, the current working directory is something like /private/var/folders/0r/y4qmws5d2tjdkqzlb19_ny1h0000gn/T.

I think this behaviour appeared with the last TextMate alpha release, but reverting to the previous version was useless. Any ideas?

share|improve this question
As TextMate 2 is bleeding edge alpha, you should probably file a bug with them instead. – slhck Jun 3 '13 at 13:20
@slhck Well, I'm not sure this is a bug. May be I just need to tweak some environment variable in the prefs. I'll surely file a bug otherwise. Thanks! – Aristide Jun 3 '13 at 14:11
up vote 2 down vote accepted

The working directory of the command being executed is unspecified except for drop commands (where it is the parent of the current file). We have never documented what the working directory is set to, and if you need it to be set to something specific (e.g. TM_PROJECT_DIRECTORY) then you should set it yourself.

I don't know how you're supposed to change the working directory though. Setting PWD to $TM_PROJECT_DIRECTORY in the variables tab didn't work. As a temporary measure, I added this to the commands for running scripts in the Ruby and shell script bundles:

share|improve this answer
Thanks! Following your advice, I've added the following to the command for running Python scripts: Dir.chdir(ENV["TM_DIRECTORY"]) (i.e., the folder of the current document). It works fine! – Aristide Jun 4 '13 at 8:14

Your Answer


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.