trzsz is a simple file transfer tools, similar to lrzsz ( rz / sz ) but compatible with tmux, which works with iTerm2 and has a nice progress bar.
Project description
trzsz
trzsz is a simple file transfer tools, similar to lrzsz ( rz / sz ) but compatible with tmux.
which works with iTerm2 and has a nice progress bar.
Website: https://trzsz.github.io
Why?
I love to use iTerm2 integrating with tmux to manage terminal sessions.
Sometimes, I need to transfer some files between my laptop and the remote server.
Considering laptop -> hostA -> hostB -> docker -> tmux
, using scp to transfer files is inconvenience.
Tmux is not going to support lrzsz ( rz / sz ) ( 906, 1439 ), and I found out that creating a new file transfer tools is much easier than patching tmux.
Additionally, iTerm2-zmodem is not supporting a progress bar. Is there something wrong happened or just need more time?
Requirements
- Python
- Python’s standard library is good enough.
- iTerm2
- Tmux Integration and Coprocesses are so cool.
btw
without tmux works too.
- zenity
- Optional for a nice progress bar.
Installation
Server side
Install trzsz-svr
sudo python3 -m pip install --upgrade trzsz-libs trzsz-svr
- Also supports Python2:
sudo pip install --upgrade trzsz-libs trzsz-svr
- Can be installed without
sudo
, but need to add the installation path ( may be~/.local/bin
) to the PATH environment. trz -v
ortsz -v
output the version of trzsz means successfully installed. Otherwise, check the output of the previous installation.
Client side
Install trzsz-iterm2
sudo python3 -m pip install --upgrade trzsz-libs trzsz-iterm2
- Also supports Python2:
sudo pip install --upgrade trzsz-libs trzsz-iterm2
which trzsz-iterm2
output/usr/local/bin/trzsz-iterm2
means successfully installed. if not:which trzsz-iterm2
shows nothing, check the output of the previous installation.which trzsz-iterm2
shows another path, create a soft link:
sudo ln -sv $(which trzsz-iterm2) /usr/local/bin/trzsz-iterm2
Install iTerm2 and create a Trigger as follows.
Name | Value | Note |
---|---|---|
Regular Expression | :(:TRZSZ:TRANSFER:[SR]:\d+\.\d+\.\d+:\d+) |
No space at the end |
Action | Run Silent Coprocess |
|
Parameters | /usr/local/bin/trzsz-iterm2 \1 |
No space at the end |
Enabled | ✅ | Checked |
-
Don't check the
Use interpolated strings for parameters
at the bottom. -
Note that the
Trigger
should be configured for eachProfile
in use. -
iTerm2 Trigger configuration allows input multiple lines, but only shows one line. Make sure don't copy a newline into it.
Optional
install zenity for a nice progress bar.
brew install ncruces/tap/zenity
- If
Mac M1
install fails, try to install withgo
:brew install go go install 'github.com/ncruces/zenity/cmd/zenity@latest' sudo cp ~/go/bin/zenity /usr/local/bin/zenity
which zenity
output/usr/local/bin/zenity
means successfully installed. if not:which zenity
shows nothing, check the output of the previous installation.which zenity
shows another path, create a soft link:
sudo ln -sv $(which zenity) /usr/local/bin/zenity
Manual
trz
upload files to remote server
usage: trz [-h] [-v] [-q] [-y] [-b] [-e] [-B N] [-t N] [path]
Receive file(s), similar to rz but compatible with tmux.
positional arguments:
path path to save file(s). (default: current directory)
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-q, --quiet quiet (hide progress bar)
-y, --overwrite yes, overwrite existing file(s)
-b, --binary binary transfer mode, faster for binary files
-e, --escape escape all known control characters
-B N, --bufsize N buffer chunk size ( 1K <= N <= 100M ). (default: 1M)
-t N, --timeout N timeout ( N seconds ) for each buffer chunk.
N <= 0 means never timeout. (default: 100)
tsz
download files from remote server
usage: tsz [-h] [-v] [-q] [-y] [-b] [-e] [-B N] [-t N] file [file ...]
Send file(s), similar to sz but compatible with tmux.
positional arguments:
file file(s) to be sent
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-q, --quiet quiet (hide progress bar)
-y, --overwrite yes, overwrite existing file(s)
-b, --binary binary transfer mode, faster for binary files
-e, --escape escape all known control characters
-B N, --bufsize N buffer chunk size ( 1K <= N <= 100M ). (default: 1M)
-t N, --timeout N timeout ( N seconds ) for each buffer chunk.
N <= 0 means never timeout. (default: 100)
Trouble shooting
-
If
tmux
is not running on the remote server, but on the local mac, or on a middle server.- Since
trzsz
can't find thetmux
process on the server, have to use thetmux -CC
control mode. - About how to use the
tmux -CC
control mode, please refer to iTerm2 tmux Integration.
- Since
-
If an error occurs, and
trzsz
is hanging up.- Press
command + option + shift + r
to stop iTerm2 Coprocesses. - Press
control + c
to stoptrz
ortsz
process on the server.
- Press
-
If
trz -b
binary upload fails, and login to server usingtelnet
ordocker exec
.- Try to escape all known control characters, e.g.,
trz -eb
.
- Try to escape all known control characters, e.g.,
-
If
trz -b
binary upload fails, and the server is usingPython3 < 3.7
.Python3 < 3.7
supports base64 mode, just don't usetrz -b
, usetrz
instead.- If you want to use
trz -b
binary upload, upgrade Python3 to above 3.7, or use Python2.
-
If
trz -b
ortsz -b
binary transfer fails, and login to server usingexpect
.- Try to
export LC_CTYPE=C
before theexpect
script. e.g.:#!/bin/sh export LC_CTYPE=C expect -c ' spawn ssh xxx expect "xxx: " send "xxx\n" interact '
- Try to
Screenshot
Upload files to remote server
Download files from remote server
Contact
Feel free to email me lonnywong@qq.com (same as my PayPal account, just in case you want to deduct🤑).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file trzsz-svr-0.3.1.tar.gz
.
File metadata
- Download URL: trzsz-svr-0.3.1.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e2334b402a968936df312fcfaf81628c1fae08e63aa086fbfd6adacf4b89257 |
|
MD5 | 7c017130eb6bd6274f008abac331c8ab |
|
BLAKE2b-256 | e97a147baf7c62f25bc39c50dbdbad469da9536c592cc53de9cfb71c86256a1c |
File details
Details for the file trzsz_svr-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: trzsz_svr-0.3.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21d886118aed25477d41d5e7af03c9b28ae00f4d1514311d829aa63c38f33ee4 |
|
MD5 | 64d6076b9794a9809496f97902fa7fac |
|
BLAKE2b-256 | e86772d345748424b9e5c804a57a1b530a2654495c6fdb6ced230b4f27a15271 |