brew install lrzsz安装成功后,会在以下路径生成两个可执行文件(具体的路径取决于brew配置,可以用find查找一下)
/usr/local/Cellar/lrzsz/0.12.20/bin/rz
/usr/local/Cellar/lrzsz/0.12.20/bin/sz
建立符号连接
ln -s /usr/local/Cellar/lrzsz/0.12.20/bin/sz /usr/local/bin/sz
ln -s /usr/local/Cellar/lrzsz/0.12.20/bin/rz /usr/local/bin/rz
源码:https://github.com/mmastrac/iterm2-zmodem
注意黄色字体,需要修改为实际sz与rz的路径
cd /usr/local/bin/
wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-send-zmodem.sh
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 domain
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)&\"\")"`
if [[ $FILE = "" ]]; then
echo Cancelled.
# Send ZModem cancel
echo -e \\x18\\x18\\x18\\x18\\x18
echo \# Cancelled transfer
echo
else
echo $FILE
/usr/local/bin/sz "$FILE"
echo \# Received $FILE
echo
fi
wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-recv-zmodem.sh
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 domain
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)&\"\")"`
if [[ $FILE = "" ]]; then
echo Cancelled.
# Send ZModem cancel
echo -e \\x18\\x18\\x18\\x18\\x18
echo \# Cancelled transfer
echo
else
echo $FILE
cd "$FILE"
/usr/local/bin/rz
echo \# Received $FILE
echo
fi
