1 Star 2 Fork 0

trzsz / trzsz-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

trzsz-go ( trz / tsz ) - 推荐 Go 版 trzsz

MIT License GitHub Release WebSite 中文文档

trzsz-go 使所有支持本地 shell 的终端都支持 trzsz ( trz / tsz —— 和 rz / sz 类似、兼容 tmux )。

⭐ 推荐在服务器上使用 go 版 trzsz,在本地电脑使用 trzsz-ssh ( tssh )

有关 trzsz ( trz / tsz ) 更详细的文档,请查看 https://trzsz.github.io/cn

安装方法

  • Ubuntu 可用 apt 安装

    sudo apt install trzsz
    sudo apt update && sudo apt install software-properties-common
    sudo add-apt-repository ppa:trzsz/ppa && sudo apt update
    
    sudo apt install trzsz
  • Debian 可用 apt 安装

    sudo apt install trzsz
    sudo apt install curl gpg
    curl -s 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x7074ce75da7cc691c1ae1a7c7e51d1ad956055ca' \
        | gpg --dearmor -o /usr/share/keyrings/trzsz.gpg
    echo 'deb [signed-by=/usr/share/keyrings/trzsz.gpg] https://ppa.launchpadcontent.net/trzsz/ppa/ubuntu jammy main' \
        | sudo tee /etc/apt/sources.list.d/trzsz.list
    sudo apt update
    
    sudo apt install trzsz
  • Linux 可用 yum 安装

    sudo yum install trzsz
    • 国内推荐使用 wlnmp 源,安装 trzsz 只需要添加 wlnmp 源( 配置 epel 源不是必须的 ):

      curl -fsSL "https://sh.wlnmp.com/wlnmp.sh" | bash
      
      sudo yum install trzsz
    • 也可使用 gemfury 源( 只要网络通,所有操作系统通用 )

      echo '[trzsz]
      name=Trzsz Repo
      baseurl=https://yum.fury.io/trzsz/
      enabled=1
      gpgcheck=0' | sudo tee /etc/yum.repos.d/trzsz.repo
      
      sudo yum install trzsz
  • ArchLinux 可用 yay 安装

    yay -S trzsz
    yay -Syu
    yay -S trzsz
  • MacOS 可用 homebrew 安装

    brew install trzsz-go
    brew update
    brew install trzsz-go
  • Windows 可用 scoop / winget / choco 安装

    scoop install trzsz / winget install trzsz / choco install trzsz
    scoop install trzsz
    winget install trzsz
    choco install trzsz
  • 用 Go 直接安装( 要求 go 1.20 以上 )

    go install github.com/trzsz/trzsz-go/cmd/...@latest
    go install github.com/trzsz/trzsz-go/cmd/trz@latest
    go install github.com/trzsz/trzsz-go/cmd/tsz@latest
    go install github.com/trzsz/trzsz-go/cmd/trzsz@latest

    安装后,trzsz 程序一般位于 ~/go/bin/ 目录下( Windows 一般在 C:\Users\your_name\go\bin\ )。

  • 用 Go 自己编译( 要求 go 1.20 以上 )

    sudo make install
    git clone --depth 1 https://github.com/trzsz/trzsz-go.git
    cd trzsz-go
    make
    sudo make install
  • 可从 GitHub Releases 中下载,国内可从 Gitee 发行版 中下载,解压并加到 PATH 环境变量中。

使用方法

在本地电脑使用

  • 在命令前添加 trzsz,就可以支持 trzsz ( trz / tsz ) 上传和下载了,如:

    trzsz bash
    trzsz PowerShell
    trzsz ssh x.x.x.x
  • 在命令前添加 trzsz --dragfile,就可以启用拖拽上传功能,如:

    trzsz -d ssh x.x.x.x
    trzsz --dragfile ssh x.x.x.x

在跳板机上使用

  • 如果在跳板机上使用 tmux,则需要再使用 trzsz --relay ssh 登录远程服务器,如:

    trzsz ssh jump_server
    tmux
    trzsz --relay ssh remote_server

在服务器上使用

  • 与 lrzsz ( rz / sz ) 类似,使用 trz 命令上传文件,使用 tsz /path/to/file 命令下载文件。

  • 有关 trzsz 更详细的文档,请查看 https://trzsz.github.io/cn/

使用建议

  • 为了使用方便,可以设置 alias ,例如 alias ssh="trzsz ssh",又或者 alias ssh="trzsz -d ssh" 支持拖文件上传。

  • 如果在本地电脑使用 tmux,先不带 trzsz 运行 tmux,然后再使用 trzsz ssh 登录远程服务器。

可配置项

trzsz 使用的配置文件是 ~/.trzsz.conf( Windows 是 C:\Users\your_name\.trzsz.conf )。注意路径必须包含 / 结尾,如:

DefaultUploadPath =
DefaultDownloadPath = /Users/username/Downloads/
  • 如果 DefaultUploadPath 不为空,上传选择文件时会默认打开此目录。

  • 如果 DefaultDownloadPath 不为空,下载文件时会自动下载到此目录( 不需要再弹窗选择路径 )。

支持 Zmodem

  • 使用 -z--zmodem 启用 rz / sz 功能,例如 trzsz -z ssh remote_server

  • 需要在客户端( 本地电脑 )上安装 lrzsz,例如 brew install lrzszapt install lrzsz 等。

  • trzsz --zmodem ssh xxx 不兼容 Windows,你可以使用 trzsz-ssh ( tssh ) 代替,如 tssh --zmodem xxx

  • 关于进度条,己传文件大小和传输速度不是精确值,会有一些偏差,它的主要作用只是指示传输正在进行中。

常见问题

  • 如果 MSYS2Git Bash 遇到错误 The handle is invalid

    • trzsz 前面加上 winpty 即可,如 winpty trzsz ssh x.x.x.x 这样登录服务器。
    • Git Bash 已默认安装有 winptyMSYS2 需要手工安装 pacman -S winpty
  • MSYS2Cygwin 等,不支持直接使用 /usr/bin/ssh 那个 ssh,可能会传输失败。需要使用 Windows 自带的 OpenSSH

    • MSYS2 中用法 winpty trzsz /c/Windows/System32/OpenSSH/ssh.exe x.x.x.x
    • Cygwin 中用法 trzsz "C:\Windows\System32\OpenSSH\ssh.exe" x.x.x.x
    • ⭐ 推荐使用 trzsz-ssh ( tssh ),tssh 等同于 trzsz ssh
  • 拖文件或目录到终端后,没有自动上传?

    • 检查 ssh 登录时有没有加上 --dragfile 选项,如 trzsz --dragfile ssh x.x.x.x
    • 检查服务器上有没有安装 trzsztrz 应在某个 PATH 路径下。
    • 在 Windows 中,检查标题有没有管理员三个字,以管理员运行 时可能会由于 UAC 设置的原因导致拖不了文件。
    • 在 Windows Terminal 中,需要将文件或目录拖到左上角,显示粘贴文件路径 时再放开。
    • 在 Windows 的 cmdPowerShell 中,一次只能拖一个文件或目录,拖多个也只有鼠标正对着的那个是生效的。

开发指引

想要让你自己开发的 ssh 客户端支持 trzsz ?请参考 go ssh client example

录屏演示

Windows 系统

windows trzsz ssh

Ubuntu 系统

ubuntu trzsz ssh

拖拽上传

drag files ssh

联系方式

有什么问题可以发邮件给作者 lonnywong@qq.com,也可以提 Issues 。欢迎加入 QQ 群:318578930。

赞助打赏

❤️ 赞助 trzsz ❤️,请作者喝杯咖啡 ☕ ? 谢谢您们的支持!

MIT License Copyright (c) 2022-2024 The Trzsz Authors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

trzsz ( trz / tsz ) 是一个兼容 tmux 的文件传输工具,和 lrzsz ( rz / sz ) 类似,并且有进度条和支持目录传输。 展开 收起
Go 等 3 种语言
MIT
取消

发行版 (3)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/trzsz/trzsz-go.git
git@gitee.com:trzsz/trzsz-go.git
trzsz
trzsz-go
trzsz-go
main

搜索帮助