1、安装brew(找了很多🔗,就这个博主的好用)
Mac如何安装brew?_行走的码农00的博客-CSDN博客_mac brew
2、安装lrzsz
brew install lrzsz
检查是否安装成功
brew list
定位lrzsz的安装目录
brew list lrzsz
执行结果如下:
3、配置rz sz 进行上传下载
进入lrzsz的安装目录bin下
cd /opt/homebrew/bin
创建两个文件:
$FILE 后面的配置路径为:lrzsz的安装目录bin
sudo vim iterm2-recv-zmodem.sh
#!/bin/bash
# Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domainosascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
else
FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
fiif [[ $FILE = "" ]]; then
echo Cancelled.
# Send ZModem cancel
echo -e \\x18\\x18\\x18\\x18\\x18
sleep 1
echo
echo \# Cancelled transfer
else
cd "$FILE"
/opt/homebrew/bin/rz -E -e -b
sleep 1
echo
echo
echo \# Sent \-\> $FILE
fi
sudo vim iterm2-send-zmodem.sh
#!/bin/bash
# Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domainosascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
else
FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
fi
if [[ $FILE = "" ]]; then
echo Cancelled.
# Send ZModem cancel
echo -e \\x18\\x18\\x18\\x18\\x18
sleep 1
echo
echo \# Cancelled transfer
else
/opt/homebrew/bin/sz "$FILE" -e -b
sleep 1
echo
echo \# Received $FILE
fi
给予权限:
chmod -R 777 iterm2-recv-zmodem.sh
chmod -R 777 iterm2-send-zmodem.sh
4、iTerm2 配置添加rz sz 功能
点击 iTerm2 的设置界面 Perference-> Profiles -> Default -> Advanced -> Triggers 的 Edit 按钮
配置内容如下:
第一行:
rz waiting to receive.\*\*B0100
Run Silent Coprocess
/opt/homebrew/bin/iterm2-send-zmodem.sh
第二行:
\*\*B00000000000000
Run Silent Coprocess
/opt/homebrew/bin/iterm2-recv-zmodem.sh
Instant 打钩的话,不需要重启item
然后就可以使用rz、rz命令啦~