是否可以在Bash中通过管道与剪贴板进行连接?
无论是通过管道连接设备手柄还是使用辅助应用程序,我都找不到任何东西.
例如,如果/dev/clip
是链接到剪贴板的设备,我们可以:
cat /dev/clip # Dump the contents of the clipboard
cat foo > /dev/clip # Dump the contents of "foo" into the clipboard
是否可以在Bash中通过管道与剪贴板进行连接?
无论是通过管道连接设备手柄还是使用辅助应用程序,我都找不到任何东西.
例如,如果/dev/clip
是链接到剪贴板的设备,我们可以:
cat /dev/clip # Dump the contents of the clipboard
cat foo > /dev/clip # Dump the contents of "foo" into the clipboard
使用clipboard-cli.它可以与macOS、Windows、Linux、OpenBSD、FreeBSD和Android一起使用,没有任何实际问题.
安装时请使用:
npm install -g clipboard-cli
然后你可以做:
echo foo | clipboard
如果需要,可以在.bashrc
、.bash_profile
或.zshrc
中输入以下内容,将别名设置为cb
:
alias cb=clipboard