June 2009

Copy'n'Paste

Mac:

# stick in .irbrc
def copy(str)
  IO.popen('pbcopy', 'w') { |f| f << str.to_s }
end

def paste
  `pbpaste`
end

def ep
  eval(paste)
end

Linux with xclip (thanks Bjørn Arild Mæland):

def copy(str)
  IO.popen('xclip -i', 'w') { |f| f << str.to_s }
end
 
def paste
  `xclip -o`
end