From d154d5bba805fa21d36fd0b02a4df6cd4dae374d Mon Sep 17 00:00:00 2001 From: Lonny Wong Date: Sun, 14 Jul 2024 22:39:03 +0800 Subject: [PATCH] support clipboard integration via OSC52 --- README.cn.md | 14 ++++++++++++++ README.en.md | 14 ++++++++++++++ README.md | 29 +++++++++++++++-------------- tssh/trzsz.go | 4 +++- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/README.cn.md b/README.cn.md index d4da770..eed37f7 100644 --- a/README.cn.md +++ b/README.cn.md @@ -647,6 +647,20 @@ trzsz-ssh ( tssh ) 设计为 ssh 客户端的直接替代品,提供与 openssh - `Key Value # Comment` 配置(没有 `=` 号),`openssh` 有些情况认为 `#` 后的内容是注释,有些情况认为不是注释;`tssh` 一律认为 `#` 后的内容是注释。 - `Key=Value # Comment` 配置(有 `=` 号),`openssh` 有些情况认为 `#` 后的内容是注释,有些情况认为不是注释;`tssh` 一律认为 `#` 后的内容不是注释。 +## 剪贴板集成 + +- 在 `~/.ssh/config` 或 `ExConfigPath` 配置文件中,配置 `EnableOSC52` 为 `Yes` 启用剪贴板集成功能。 + + ``` + Host * + # 如果配置在 ~/.ssh/config 中,可以加上 `#!!` 前缀,以兼容标准 ssh + EnableOSC52 Yes + ``` + +- 启用剪贴板集成功能后,支持远程服务器通过 OSC52 序列写入本地剪贴板。 + +- 在 Linux 系统,剪贴板集成功能需要安装 `xclip` 或 `xsel` 命令。 + ## 其他功能 - 使用 `-f` 后台运行时,可以加上 `--reconnect` 参数,在后台进程因连接断开等而退出时,会自动重新连接。 diff --git a/README.en.md b/README.en.md index d82881e..64b2b02 100644 --- a/README.en.md +++ b/README.en.md @@ -649,6 +649,20 @@ trzsz-ssh ( tssh ) is an ssh client designed as a drop-in replacement for the op - `Key=Value # Comment` configuration (with `=` sign), `openssh` considers the content after `#` to be a comment in some cases, and considers it not to be a comment in some other cases; `tssh` always considers the content after `#` not to be a comment. +## Clipboard Integration + +- In the `~/.ssh/config` or `ExConfigPath` configuration file, configure `EnableOSC52` to `Yes` to enable the clipboard integration feature. + + ``` + Host * + # If configured in ~/.ssh/config, add `#!!` prefix to be compatible with openssh. + EnableOSC52 Yes + ``` + +- Clipboard integration allows remote servers to write to the local clipboard via OSC52 sequences. + +- On Linux, clipboard integration requires `xclip` or `xsel` command to be installed. + ## Other Features - Use `-f` to run in the background, you can add `--reconnect`, it will automatically reconnect when the background process exits. diff --git a/README.md b/README.md index 276a4f2..599beb2 100644 --- a/README.md +++ b/README.md @@ -30,20 +30,21 @@ trzsz-ssh ( tssh ) works exactly like the openssh client. The following common f trzsz-ssh ( tssh ) offers additional useful features: -| English | 中文 | -| :---------------------------------------------------------: | :-----------------------------------------------------------: | -| [Login Prompt](README.en.md#login-prompt) | [登录界面](README.cn.md#%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2) | -| [Custom Theme](README.en.md#custom-theme) | [主题风格](README.cn.md#%E4%B8%BB%E9%A2%98%E9%A3%8E%E6%A0%BC) | -| [trzsz ( trz / tsz )](README.en.md#support-trzsz) | [trzsz ( trz / tsz )](README.cn.md#%E6%94%AF%E6%8C%81-trzsz) | -| [zmodem ( rz / sz )](README.en.md#support-zmodem) | [zmodem ( rz / sz )](README.cn.md#%E6%94%AF%E6%8C%81-zmodem) | -| [Batch Login](README.en.md#batch-login) | [批量登录](README.cn.md#%E6%89%B9%E9%87%8F%E7%99%BB%E5%BD%95) | -| [Group Labels](README.en.md#group-labels) | [分组标签](README.cn.md#%E5%88%86%E7%BB%84%E6%A0%87%E7%AD%BE) | -| [Automated Interaction](README.en.md#automated-interaction) | [自动交互](README.cn.md#%E8%87%AA%E5%8A%A8%E4%BA%A4%E4%BA%92) | -| [Remember Password](README.en.md#remember-password) | [记住密码](README.cn.md#%E8%AE%B0%E4%BD%8F%E5%AF%86%E7%A0%81) | -| [Custom Configuration](README.en.md#custom-configuration) | [个性配置](README.cn.md#%E4%B8%AA%E6%80%A7%E9%85%8D%E7%BD%AE) | -| [Comments of Config](README.en.md#comments-of-config) | [配置注释](README.cn.md#%E9%85%8D%E7%BD%AE%E6%B3%A8%E9%87%8A) | -| [Other Features](README.en.md#other-features) | [其他功能](README.cn.md#%E5%85%B6%E4%BB%96%E5%8A%9F%E8%83%BD) | -| [UDP Mode](README.en.md#udp-mode) | [UDP 模式](README.cn.md#udp-%E6%A8%A1%E5%BC%8F) | +| English | 中文 | +| :---------------------------------------------------------: | :----------------------------------------------------------------------: | +| [Login Prompt](README.en.md#login-prompt) | [登录界面](README.cn.md#%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2) | +| [Custom Theme](README.en.md#custom-theme) | [主题风格](README.cn.md#%E4%B8%BB%E9%A2%98%E9%A3%8E%E6%A0%BC) | +| [trzsz ( trz / tsz )](README.en.md#support-trzsz) | [trzsz ( trz / tsz )](README.cn.md#%E6%94%AF%E6%8C%81-trzsz) | +| [zmodem ( rz / sz )](README.en.md#support-zmodem) | [zmodem ( rz / sz )](README.cn.md#%E6%94%AF%E6%8C%81-zmodem) | +| [Batch Login](README.en.md#batch-login) | [批量登录](README.cn.md#%E6%89%B9%E9%87%8F%E7%99%BB%E5%BD%95) | +| [Group Labels](README.en.md#group-labels) | [分组标签](README.cn.md#%E5%88%86%E7%BB%84%E6%A0%87%E7%AD%BE) | +| [Automated Interaction](README.en.md#automated-interaction) | [自动交互](README.cn.md#%E8%87%AA%E5%8A%A8%E4%BA%A4%E4%BA%92) | +| [Remember Password](README.en.md#remember-password) | [记住密码](README.cn.md#%E8%AE%B0%E4%BD%8F%E5%AF%86%E7%A0%81) | +| [Custom Configuration](README.en.md#custom-configuration) | [个性配置](README.cn.md#%E4%B8%AA%E6%80%A7%E9%85%8D%E7%BD%AE) | +| [Comments of Config](README.en.md#comments-of-config) | [配置注释](README.cn.md#%E9%85%8D%E7%BD%AE%E6%B3%A8%E9%87%8A) | +| [Clipboard Integration](README.en.md#clipboard-integration) | [剪贴板集成](README.cn.md#%E5%89%AA%E8%B4%B4%E6%9D%BF%E9%9B%86%E6%88%90) | +| [Other Features](README.en.md#other-features) | [其他功能](README.cn.md#%E5%85%B6%E4%BB%96%E5%8A%9F%E8%83%BD) | +| [UDP Mode](README.en.md#udp-mode) | [UDP 模式](README.cn.md#udp-%E6%A8%A1%E5%BC%8F) | ## Installation diff --git a/tssh/trzsz.go b/tssh/trzsz.go index 2fdeee3..4a1a87c 100644 --- a/tssh/trzsz.go +++ b/tssh/trzsz.go @@ -113,9 +113,10 @@ func enableTrzsz(args *sshArgs, ss *sshClientSession) error { disableTrzsz := strings.ToLower(getExOptionConfig(args, "EnableTrzsz")) == "no" enableZmodem := args.Zmodem || strings.ToLower(getExOptionConfig(args, "EnableZmodem")) == "yes" enableDragFile := args.DragFile || strings.ToLower(getExOptionConfig(args, "EnableDragFile")) == "yes" + enableOSC52 := strings.ToLower(getExOptionConfig(args, "EnableOSC52")) == "yes" // disable trzsz ( trz / tsz ) - if disableTrzsz && !enableZmodem && !enableDragFile { + if disableTrzsz && !enableZmodem && !enableDragFile && !enableOSC52 { wrapStdIO(ss.serverIn, ss.serverOut, ss.serverErr, ss.tty) onTerminalResize(func(width, height int) { _ = ss.session.WindowChange(height, width) }) return nil @@ -161,6 +162,7 @@ func enableTrzsz(args *sshArgs, ss *sshClientSession) error { DetectDragFile: enableDragFile, DetectTraceLog: args.TraceLog, EnableZmodem: enableZmodem, + EnableOSC52: enableOSC52, }) // reset terminal size on resize