Index: lib/sup/modes/thread-view-mode.rb =================================================================== --- lib/sup/modes/thread-view-mode.rb (revision 687) +++ lib/sup/modes/thread-view-mode.rb (working copy) @@ -40,6 +40,7 @@ k.add :delete_and_kill, "Delete thread and kill buffer", 'd' k.add :subscribe_to_list, "Subscribe to/unsubscribe from mailing list", "(" k.add :unsubscribe_from_list, "Subscribe to/unsubscribe from mailing list", ")" + k.add :pipe, "Pipe message/attachment to shell command", '|' end ## there are a couple important instance variables we hold to format @@ -80,6 +81,28 @@ @thread.remove_label :unread regen_text end + + def pipe + command = BufferManager.ask(nil, "shell command: ") or return + shell = Session::Shell.new + output, error = '', '' + chunk = @chunk_lines[curpos] or return + case chunk + when Chunk::Attachment + shell.execute command, :stdin => chunk.raw_content, :stdout => output, :stderr => error + else + m = @message_lines[curpos] + shell.execute command, :stdin => m.raw_message, :stdout => output, :stderr => error + end + if !error.empty? + BufferManager.flash "Error: #{error}" + elsif output.empty? + BufferManager.flash "'#{command}' done" + else + b = BufferManager.spawn "output of '#{command}'", TextMode.new(output) + b.draw + end + end def draw_line ln, opts={} if ln == curpos