有一种方法可以通过将一些命令输出放入系统剪贴板xclip
。
some-command | xclip -selection clipboard
我想执行相反的任务 - 将系统剪贴板打印到终端。怎样才能做到呢?
答案1
根据联机帮助页,可以-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
正在假设。
答案2
另一种选择是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
更多高级选项,例如应使用哪个剪贴板等。