Created
March 28, 2013 20:03
-
-
Save davidh-raybeam/5266339 to your computer and use it in GitHub Desktop.
These ruby and python scripts provide functions that allow you to copy their arguments to the clipboard.
This file contains hidden or 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 the following function definition into a file called ~/.pythonrc | |
# and add the line | |
# export PYTHONSTARTUP="$HOME/.pythonrc" | |
# to your .bash{rc,_profile} | |
import os | |
def clip(x): | |
os.popen('pbcopy','w').write(str(x)) |
This file contains hidden or 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 one of the following function definitions into a file called ~/.irbrc | |
# irb will run this file on startup | |
# For OS X | |
def clip(x) | |
IO.popen("pbcopy", "w") do |pb| | |
pb.write(x.to_s) | |
end | |
x | |
end | |
# For Linux | |
# Install xclip first ([sudo] apt-get install xclip on debian-like systems) | |
# Note: I have not tested this yet, but the internets seem to suggest xclip is the answer | |
# If this does not work, try changing the command to "xclip -selection clipboard" | |
def clip(x) | |
IO.popen("xclip", "w") do |xc| | |
xc.write(x.to_s) | |
end | |
x | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment