Sublime Forum

Run arbitrary shell commands in Sublime

#1

Build systems are a pretty useful feature of Sublime, but for a lot of projects it’s easier to just have a quick way of running arbitrary shell commands. If you’re on a Ruby project, for instance, it’s pretty wonky to create a build system for “rake”, “test”] and “rake”, “test:units”] and “rake”, “test:functionals”] etc.

I created plugin that’s turned out to be pretty handy for me, and it’s dead simple. Ctrl+Shift+C (Cmd+Shift+C) brings up a “shell” prompt right within Sublime. You can download it and check out out some documentation/screenshots here:
github.com/misfo/Shell-Turtlestein

Cheers,
Trent

0 Likes

#2

I like your PAQ.

Also, nice :smile:

0 Likes

#3

I don’t see this listed in package control currently. Any plan of getting this into package control?

0 Likes

#4

I just sent a pull request to have it included: github.com/wbond/package_contro … l/pull/147. Thanks for the suggestion

0 Likes

#5

Has been waiting for this ever since! Now I will just wait for it in Package Control and I’m happy!

Thanks!

0 Likes

#6

[quote=“Esente”]Has been waiting for this ever since! Now I will just wait for it in Package Control and I’m happy!

Thanks![/quote]

It’s up on package control now. Enjoy!

0 Likes

#7

Thank you so much for this plugin. Quick question. How would you set your bin path to something else like “path”: “/usr/local/bin:$PATH” ?

0 Likes

#8

I have this gist.github.com/801c5fac14fe6f0441db but then no commands will run at all…

0 Likes

#9

I modified the file Shell Turtlestein.sublime-settings to add the paths needed, and I can now run a shell command within Sublime.

{ // Override these in your own // `Packages/User/Shell Turtlestein.sublime-settings` file. "surround_cmd": "", ""], "exec_args": {"path": "/usr/texbin:/usr/local/bin:$PATH"}, "cmd_settings": ], "input_widget": { // overridden for silly non-unixy OSes "syntax": "Packages/ShellScript/Shell-Unix-Generic.tmLanguage" } }

0 Likes

#10

I don’t have a github account, so I’am posting here:
I made some modification in the replace method:

--- shell_turtlestein.py        2014-06-13 11:35:51.622084385 +0200
+++ shell_turtlestein.py.orig   2014-06-13 11:34:26.664581564 +0200
@@ -184,8 +184,8 @@
     Replace the text in the specified region with the specified text
     """
     def run(self, edit, region_start=None, region_end=None, text=None):
-        if region_start is not None and region_end is not None:
-            self.view.replace(edit, sublime.Region(region_start, region_end), text.strip())
+        if region_start and region_end:
+            self.view.replace(edit, sublime.Region(region_start, region_end), text)
         else:
             self.view.insert(edit, 0, text)

This fixes a problem when the selection starts at the beginning of the view and removes the trailing new line from the new text.

0 Likes