Created
October 1, 2012 12:48
-
-
Save karmi/3811569 to your computer and use it in GitHub Desktop.
Run selection as command in Sublime Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sublime, sublime_plugin | |
# Select some text and execute it through bash | |
# | |
class RunSelectionAsCommandCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
for region in self.view.sel(): | |
if not region.empty(): | |
# Get the selected text | |
command = self.view.substr(region) | |
print '========================================================================' | |
print command | |
print '------------------------------------------------------------------------' | |
print os.popen(command).read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment