用bash打印系统剪贴板内容


Answers:


8

根据联机帮助页的-o选项,xclip将数据推向相反的方向:

   -i, -in
          read text into X selection from standard input or files (default)

   -o, -out
          prints the selection to standard out (generally for piping to a file or program)

在上面的命令中,-i假定为。


7

另一个选择是xsel程序:

By default, this program outputs the selection without modification  if
   both  standard  input  and standard output are terminals (ttys). Other
   wise, the current selection is output if standard output is not a  ter
   minal  (tty),  and the selection is set from standard input if standard
   input is not a terminal (tty). If any input or output options are given
   then the program behaves only in the requested mode.

因此,只需将某些内容复制到剪贴板,然后运行xsel即可将其打印到终端。您可以通读man xsel更多高级选项,例如应使用哪个剪贴板等。


5
为简化起见,这就是我的工作:alias pbcopy='xsel --clipboard --input'; alias pbpaste='xsel --clipboard --output' 我选择了与MacOS命令匹配的名称。
Bananguin 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.