Last active
December 14, 2015 05:19
-
-
Save JosephPecoraro/5034544 to your computer and use it in GitHub Desktop.
Basic "Filter Through Command" TM2 command.
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
#!/usr/bin/env ruby -wKU | |
require "tempfile" | |
require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate" | |
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb" | |
command = TextMate::UI.request_string(:title => 'Filter Through Command', :prompt => 'Command:', :button1 => 'Execute', :button2 => 'Cancel').to_s | |
tempfile = Tempfile.new("tm-filter-command") | |
tempfile.write(STDIN.read) | |
tempfile.flush | |
print %x{ cat #{tempfile.path} | #{command} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment