我使用的是 Windows 10。我打开 Git Bash,然后通过 ssh 进入 Ubuntu 服务器。我经常想复制一个大文本文件的全部内容。
有时我宁愿快速将内容复制到剪贴板,而不是使用 scp 将文件下载到我的 Windows 计算机。
Using cat
然后滚动数千行,然后手动复制到剪贴板是可能的,但不切实际。
我宁愿管cat
将输出复制到我的 Windows 剪贴板的命令。或者调用其他命令,例如xclip
.
https://unix.stackexchange.com/questions/211817/copy-the-contents-of-a-file-into-the-clipboard-without-displaying-its-contents and 如何将命令的输出直接复制到剪贴板中?是类似的问题,但是xclip
导致此错误:
xclip -sel c < /etc/php/7.4/cli/php.ini
Error: Can't open display: (null)
更新后comment:
https://stackoverflow.com/a/39556508/470749很有趣,但是X11Forwarding yes
已经在我的服务器配置中,当我在前面添加时ForwardX11 yes
to ~/.ssh/config
然后跑了ssh -v -X -t -i ~/.ssh/id_rsa myuser@■■.■■■.■■■.■■
,我仍然得到:
debug1: No xauth program.
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
然后当我跑的时候xsel -b < /etc/php/7.4/cli/php.ini
:
xsel: Can't open display: (null)
: Inappropriate ioctl for device
Maybe Windows 上 Git Bash 中的 X 会话?会进一步帮助我。