Sublime Forum

ST3: Launching external tools that aren't build tools

#1

I would like to run some external tools that require their output to be parsed, independently of my default build scripts. For example, I have a tool that searches all source files for some identifiers that I can then jump to. The problem is that there’s no way for me to have these two independent of each other, i.e. if I have Project A, B, and C, I want them each to be able to run Tool Z without having to put Tool Z into each of the build scripts as a variant. That’s possible, but it’s inconvenient (e.g. if I change Tool Z I have to now go and find all build scripts that reference it). My other option is to make a separate build script for Tool Z and then select it every time I need to use it, but that’s inconvenient.

Is there a simpler way to do this? I can’t just bind Tool Z to a key because I need to filter the output so I can jump to code. I could write a plug in that would select Tool Z as the build system and execute it and then reset the build system, but I’m not sure exactly how to do that.

0 Likes

#2

Build systems are mostly just a frontend for the exec command (defined in exec.py in the default package), so you can write a plugin that calls the exec command directly. The only holdup is that you’ll have to do the variable substitution yourself ($file and friends), as that’s done by the build command before it forwards the arguments to the exec command.

0 Likes

#3

Somewhat related, when sublime text is launched from a commandline is it then possible to refer to the “current working directory” in a build system? E.g.

{
	"shell_cmd": "make",
	"working_dir": "${current_working_dir}",
}

would work as if ‘make’ was executed from the commandline.

0 Likes

#4

I just found out that ‘start sublime_text.exe .’ on Windows will start sublime text with a project at the current directory. I can then use ‘project_path’ to get the current directory in the build system instead of introducing a new build system variable ${current_working_dir}.

0 Likes

#5

Sorry if I’m being daft here, but where do I find exec.py in the ST3 installation? I’m using the portable version on Windows.

0 Likes

#6

In my installation, I found ‘exec.py’ in the ‘Default.sublime-package’ archive under ‘C:\Program Files\Sublime Text 3\Packages’.

0 Likes

#7

Ah, I hadn’t realized that those were ZIP files. :blush:

0 Likes