之前也有配置iterm2的rz sz命令,最近也有用到就记录下,
配置很简单。主要按照如下(下载zmoden脚本):
https://github.com/mmastrac/iterm2-zmodem
首先安装lrzsz。
brew install lrzsz
ZModem integration for iTerm 2
This script can be used to automate ZModem transfers from your OSX desktop to a server that can run lrzsz (in theory, any machine that supports SSH), and vice-versa.
The minimum supported iTerm2 version is 1.0.0.20120108
Troubleshooting
- Sending a directory may fail: this is a known issue
- If you are using
tmuxor some other terminal multiplexer (ie:screen), try using the-eoption toszand/orrzon your server to force escaping of more characters during transmission. - This tool may also fail if you are using
expectorrloginas it expects a mostly-clean 8-bit connection between the two parties.
Setup
- Install lrzsz on OSX:
brew install lrzsz - Save the
iterm2-send-zmodem.shanditerm2-recv-zmodem.shscripts in/usr/local/bin/ - Set up Triggers in iTerm 2 like so:
Regular expression: rz waiting to receive.\*\*B0100
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-send-zmodem.sh
Instant: checked
Regular expression: \*\*B00000000000000
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-recv-zmodem.sh
Instant: checked
To send a file to a remote machine:
- Type
rzon the remote machine - Select the file(s) on the local machine to send
- Wait for the coprocess indicator to disappear
The receive a file from a remote machine
- Type
sz filename1 filename2 … filenameNon the remote machine - Select the folder to receive to on the local machine
- Wait for the coprocess indicator to disappear
Future plans (patches welcome)
- Visual progress bar indicator
将iterm2-send-zmodem.sh 和 iterm2-recv-zmodem.sh脚本下载下来并放到/usr/local/bin/目录下,注意赋予脚本执行的权限
如图,打开iterm2
同时按 command和,键
Profiles – Default – Advanced – Triggers的Edit按钮,
在弹出的界面配置以下参数
可以正常向服务器上传文件了。



