Skip to content

Commit

Permalink
added _cp to irbrc
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Jan 29, 2010
1 parent b0357c5 commit c26d025
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions irbrc 100644 → 100755
Expand Up @@ -35,6 +35,16 @@ class Object
end
end

def _cp(kopimi = Readline::HISTORY.entries[-2], options = {})
if kopimi.respond_to?(:join) && !options[:to_a]
kopimi = kopimi.map{|i| ":#{i.to_s}" } if options.delete(:to_sym)
delicious = kopimi.join(", ")
elsif kopimi.respond_to?(:inspect)
delicious = kopimi.is_a?(String) ? kopimi : kopimi.inspect
end
IO.popen('pbcopy', 'w') { |io| io.write(delicious) }
end

def copy(str)
IO.popen('pbcopy', 'w') { |f| f << str.to_s }
end
Expand Down

0 comments on commit c26d025

Please sign in to comment.