Skip to content

Commit

Permalink
support clipboard integration via OSC52
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnywong committed Jul 14, 2024
1 parent eaad80e commit d154d5b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 15 deletions.
14 changes: 14 additions & 0 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 参数,在后台进程因连接断开等而退出时,会自动重新连接。
Expand Down
14 changes: 14 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion tssh/trzsz.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d154d5b

Please sign in to comment.