Created
April 30, 2011 14:30
-
-
Save ahoward/949714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in your .irbrc and then you can do | |
# | |
# irb-prompt > data = api.call | |
# irb-prompt > c data.to_json | |
# | |
# which will copy the data to your clipboard. general usage is | |
# | |
# c(stuff, stuff, stuff) | |
# | |
# | |
module Kernel | |
private | |
def c(*args) | |
buf = args.join | |
fork{ fork{ IO.popen('pbcopy', 'w'){|fd| fd.write(buf)} }; exit!(0) } | |
end | |
end |
Nice for OSX.. for linux just use
xself --clipboard --input insteast of pbcopy :)
Oh and nice to add also
def paste()
fork{ fork{ IO.popen('pbpaste', 'w'){|fd| fd.write(buf)} }; exit!(0) }
end
or xsel --clipboard --output
moving all of this into a gem -> https://github.com/ahoward/irbcp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/881388/what-is-the-reason-for-performing-a-double-fork-when-creating-a-daemon
this is some of the 'standard' practice of creating a daemon:
ref:
Advanced Programming in the Unix Environment
W. Richard Stevens, 1992, Addison-Wesley, ISBN 0-201-56317-7.