Skip to content

Instantly share code, notes, and snippets.

@JosephPecoraro
Last active December 14, 2015 05:19
Show Gist options
  • Save JosephPecoraro/5034544 to your computer and use it in GitHub Desktop.
Save JosephPecoraro/5034544 to your computer and use it in GitHub Desktop.
Basic "Filter Through Command" TM2 command.
#!/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