#!/usr/bin/env ruby require "rubygems" require "pastejour" multiple = ARGV.delete("-m") teeing = ARGV.delete("-t") || false name = ARGV.shift if $stdin.tty? name = /#{ENV["USER"]}$/ if name.nil? || name.empty? $stdout.write(Pastejour.get(name)) $stdout.flush else name = [ENV["USER"], name].compact.join("-") contents = $stdin.read Pastejour.serve(name, multiple, contents) puts contents if teeing end