Sublime Forum

Variables for custom build cmd - [solved]

#1

Hi, just started using ST2 and would like to use it with Python VirtualEnv.

I created a new .sublime-build file with following content.

{ "cmd": "/Path/to/VirtualEnv/bin/python", "/Another/Path/to/myscript.py"] }

this works just fine … but this feels a bit restricted, as my .py-file is hardcoded into the custom build system.

I would like to use something like this (Pseudo-)Code:

{ "cmd": "/Path/to/VirtualEnv/bin/python", $CurrentFile] }

Where “$CurrentFile” would point to the file, which tab is in the foreground and Cmd+B (OS X) therefore is triggered for that file’s building or here more executing purpose.

I tried without the , "/Another/Path/to/myscript.py" part, which seemingly did not execute the file’s tab currently in foreground and focus, it only opened the Python environment in the Console of ST2.

I assume something like ‘self’ or ‘this’ might be the key, but I do not find the syntax Sublime Text 2 expects. here.

Thanks in advance for any help or hint,

Cheers,
Ulf

0 Likes

#2

Have a look here. I think this is what are you looking for.

0 Likes

#3

Thanks a lot - I just found myself and wanted to close this :wink: … when I checked the ‘unofficial’ one.

So for anyone else, here is the code for a PythonVirtualEnv.sublime-build file:

[code]{
“cmd”: “/Path/to/VirtualEnv/bin/python”, “$file”]
}

[/code]

Happy coding!

Cheers,
Ulf

0 Likes