Post skimmers: I bold information that should be enough if you're familiar with Sublime Text.
I wanted to write a really quick script in Sublime Text 3 that I could debug and run without having to switch windows. I was a bit surprised that there isn't a zero-config, quick-install package. However, the config needed is very minimal.
Open the Command Palette (⌘⇧P) and choose "Build: New Build System",
In the file that then pops up, replace the contents with 1:
{
"cmd" : ["bash", "$file"],
"selector" : "source.shell"
}
Save it as bash.sublime-build
in the suggested directory, which should be anywhere in Sublime's Packages directory.
Now if you open up a shell script, you can execute it through Sublime Text and have the output pop up in Sublime Text's console by running "Build With: bash" in the Command Palette.
Note: Sublime Text could have a different $PATH
loaded, in which case you may have to pass in a path
key into the config, e.g.:
{
"cmd" : ["bash", "$file"],
"selector" : "source.shell",
"path" : "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
}
Extra links:
- http://docs.sublimetext.info/en/latest/reference/build_systems.html has more information on how to create more complex build systems
Footnotes:
1 Credit for these snippets go to this gist thread