是否可以在 Bash 中与剪贴板进行管道传输?
无论是与设备手柄之间的管道还是使用辅助应用程序,我都找不到任何东西。
例如,如果 /dev/clip
是链接到剪贴板的设备,我们可以这样做:
cat /dev/clip # Dump the contents of the clipboard
cat foo > /dev/clip # Dump the contents of "foo" into the clipboard
原文由 moinudin 发布,翻译遵循 CC BY-SA 4.0 许可协议
2018年答案
使用 剪贴板-cli 。它适用于 macOS、Windows、Linux、OpenBSD、FreeBSD 和 Android,没有任何实际问题。
安装它:
然后你可以这样做:
If you want, you can alias to
cb
by putting the following in your.bashrc
,.bash_profile
, or.zshrc
: