Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Set rz and sz on Mac

There are a mess of troubles in sending and receiving files from my macbook to dev server, since I had no permission to excute command scp on dev server. Here is a lightweight, quick, and convenience tools which related with ssh, called lrzsz. lrzsz is a unix communication package providing the XMODEM, YMODEM, ZMODEM file transefer protocol which usually has been already installed in most of servers.

Prerequisites

  • iTerm2 is necessary. Here is the official website.
  • Install lrzsz on your mac:
sudo brew install lrzsz

Set trigger for iTerm2

  • First you should download the scripts from ZModem integration for iTerm 2, and save them in /usr/local/bin/
  • Set up two triggers in iTerm2's [preference] -> [profile] -> [advanced] -> [triggers] -> [edit]
	Regular expression: rz waiting to receive.\*\*B0100
    Action: Run Silent Coprocess
    Parameters: /usr/local/bin/iterm2-send-zmodem.sh

    Regular expression: \*\*B00000000000000
    Action: Run Silent Coprocess
    Parameters: /usr/local/bin/iterm2-recv-zmodem.sh

How to use it

rz

  • Run "rz" on dev server. Then it would prompt that something like "rz waiting to receive." and create a new window titled "choose a file to send".
  • Choose the file you need to receive from your laptop.

sz

  • run "sz /path/file" to send server's file to your laptop.
@hzyfox

This comment has been minimized.

Copy link

@hzyfox hzyfox commented Aug 30, 2018

how can i find the file in my laptop when I use sz /path/file, can I specify a directory to receive the file

@meowoodie

This comment has been minimized.

Copy link
Owner Author

@meowoodie meowoodie commented Oct 23, 2018

how can i find the file in my laptop when I use sz /path/file, can I specify a directory to receive the file

Yes, you can definitely do that.

@vuther

This comment has been minimized.

Copy link

@vuther vuther commented Mar 19, 2019

Great tutorial! Is there a way to set this up so someone can drag a file to the terminal tab and it automatically send it to the server?

@axiaoxin

This comment has been minimized.

Copy link

@axiaoxin axiaoxin commented Oct 30, 2019

ZModem integration for iTerm 2 link is 404

@geekscrapy

This comment has been minimized.

Copy link

@geekscrapy geekscrapy commented Nov 13, 2019

You dont need lrzsz on the remote host do you?

@dalei2019

This comment has been minimized.

Copy link

@dalei2019 dalei2019 commented Nov 17, 2019

ZModem integration for iTerm 2 link is 404

@axiaoxin

yes , source link is 404!
I downloaded a few months ago,checkout my gist link.
send script:https://gist.github.com/dalei2019/f264f4e2fa04892da66435b174ef1a21
recv script:https://gist.github.com/dalei2019/e6ba610a831d7c7a7081672bf10869b6

@axiaoxin

This comment has been minimized.

Copy link

@axiaoxin axiaoxin commented Nov 18, 2019

thanks you @dalei2019 , I figured it out on this page https://segmentfault.com/a/1190000012166969

ps. 你贴的这个代码 第7行建议删了

@dalei2019

This comment has been minimized.

Copy link

@dalei2019 dalei2019 commented Nov 18, 2019

thanks you @dalei2019 , I figured it out on this page https://segmentfault.com/a/1190000012166969

ps. 你贴的这个代码 第7行建议删了

MD,没注意,已删除第7行。过几天我重写一个。

@qixiaobo

This comment has been minimized.

Copy link

@qixiaobo qixiaobo commented May 12, 2020

I have a lot of profiles~ How to batch add this?

@qixiaobo

This comment has been minimized.

@utf7

This comment has been minimized.

Copy link

@utf7 utf7 commented Dec 2, 2020

这个有问题,rz 一个大文件(其实也不大,比如200M)就会OOM ,不知道大家有没有遇到过?怎么解决的?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment