[英]How to send data to local clipboard from a remote SSH session
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first:) Borderline ServerFault 问题,但我正在编写一些 shell 脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数 *nixes 都有一个命令,可以让您通过管道/重定向 output 到本地剪贴板/粘贴板,并从中检索。 On OS X these commands are在 OS X 上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过 SSH 连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(颤抖)使用我的鼠标来 select 来自命令的文本,但我已经习惯了将 output 直接移到剪贴板的工作流程,我希望我的远程会话也一样。
Code is useful, but general approaches are appreciated as well.代码很有用,但一般方法也很受欢迎。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
If you use iTerm2 on the Mac, there is an easier way.如果你在 Mac 上使用iTerm2 ,有一个更简单的方法。 This functionality is built into iTerm2's Shell Integration capabilities via the it2copy
command:此功能通过it2copy
命令内置到 iTerm2 的Shell 集成功能中:
Usage: it2copy
Copies to clipboard from standard input
it2copy filename
Copies to clipboard from file
To make it work, choose iTerm2-->Install Shell Integration menu item while logged into the remote host, to install it to your own account.要使其工作,请在登录远程主机时选择iTerm2-->Install Shell 集成菜单项,将其安装到您自己的帐户。 Once that is done, you'll have access to it2copy
, as well as a bunch of other aliased commands that provide cool functionality.完成后,您将可以访问it2copy
以及许多其他提供很酷功能的别名命令。
The other solutions here are good workarounds but this one is so painless in comparison.这里的其他解决方案是很好的解决方法,但相比之下,这个解决方案非常轻松。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Borderline ServerFault问题,但是我正在编程一些shell脚本,所以我先在这里尝试:)
Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same.大多数* nixes都有一个命令,使您可以将输出通过管道传输/重定向到本地剪贴板/粘贴板,并从中进行检索。 On OS X these commands are在OS X上,这些命令是
pbcopy, pbpaste
Is there anyway to replicate this functionality while SSHed into another server?无论如何,在通过SSH连接到另一台服务器时是否可以复制此功能? That is,那是,
And yes, I know I could just (shudder) use my mouse to select the text from the command, but I've gotten so used to the workflow of pipping output directly to the clipboard that I want the same for my remote sessions.是的,我知道我可以(使用鼠标)从命令中选择文本,但是我已经习惯了将输出直接拖到剪贴板的工作流程,因此我希望远程会话也能做到这一点。
Code is useful, but general approaches are appreciated as well.代码是有用的,但也欢迎使用一般方法。
If you're working over eg a pod in a Kubernetes cluster and not direct SSH, so that there is no way for your to do a file transfer, you could use cat
and then save the terminal output as text.如果您正在处理例如 Kubernetes 集群中的 pod 而不是直接 SSH,这样您就无法进行文件传输,您可以使用cat
然后将终端 Z78E6221F63983D1356681DB3 保存为文本。 For example in macOS you can do Shell -> Export as text.例如,在 macOS 中,您可以执行 Shell -> 导出为文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.