#!/usr/bin/env ruby -w require "open3" require "#{ENV["TM_SUPPORT_PATH"]}/lib/dialog" STDOUT.sync = true key = Dialog.request_string( :prompt => "Key to use (blank for default)", :button1 => "OK" ) pp = Dialog.request_secure_string( :prompt => "Enter your passphrase", :button1 => "OK" ) cmd = "/opt/local/bin/gpg --clearsign --batch --no-tty --passphrase=#{pp}" if key != nil && key != "" cmd += " -u #{key}" end stdin, stdout, stderr = Open3.popen3( cmd ) if ENV["TM_SELECTED_TEXT"] stdin.puts ENV["TM_SELECTED_TEXT"] else $stdin.each do |s| stdin.puts s end end stdin.close out = stdout.readlines err = stderr.readlines stdout.close stderr.close puts out