I don’t think a normal user who only uses one system would need a clipboard function on different platform, but if you are coding something for multi-platform, then xerox is one of possible Python libraries and command-line programs for that.
Basically, you does things like as normal user to copy or to yank text:
$ xerox arguments all go to clipboard $ echo 'or you could echo it' | xerox $ <the_file.txt xerox $ cat or_this_file.txt | xerox
To paste, simply invoke the CLI without any arguments and it would spit out everything in clipboard:
$ xerox
Note that you may need to install from latest Git for command-line interface, the latest version 0.3.1 on PyPI still doesn’t have xerox command:
$ pip install git+https://github.com/kennethreitz/xerox.git
Programmatically, you does like:
import xerox as x # throw things into clipboard x.copy('text') # get stuff out from clipboard result = x.paste()
It’s as easy as that and it supports Linux, Mac OS X, and Windows. If you don’t like xerox, there is another one called copypaste. Both are more or less than same, requires xclip on Linux.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.