一、安装ITerm2,官网自行下载就可以(mac终端不支持lrzsz,所以需要下载个支持的)

二、安装brew,Mac默认安装了ruby,打开终端执行如下命令:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

如下载不了可以访问国内资源

HomebrewCN: Homebrew 国内安装脚本

三、安装lrzsz

lrzsz是一款在linux里可代替ftp上传和下载的程序。它使用unix通信套件提供的X,Y,和ZModem文件传输协议。通过下载它来使用rz,sz。

执行命令:

brew install lrzsz

四、安装wget

下载lrzsz之后,需要使用wget下载iterm2-zmodem。Mac默认不安装wget,可以通过brew安装。

执行命令:

brew install wget

五、下载iterm2-zmodem

在iTerm2中使用Zmodem传输文件。

执行命令:

cd /usr/local/bin
wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-send-zmodem.sh
wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-recv-zmodem.sh
chmod 777 /usr/local/bin/iterm2-*

如果命令需要权限,尝试在命令前面加上sudo

六、如果第四五步出现问题下载不了脚本文件手动创建脚本

cd /usr/local/bin
touch iterm2-recv-zmodem.sh
touch iterm2-send-zmodem.sh
vim iterm2-recv-zmodem.sh

#!/bin/bash
osascript -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)&\"\")"`
fi
 
if [[ $FILE = "" ]]; then
    echo Cancelled.
    # Send ZModem cancel
    echo -e \\x18\\x18\\x18\\x18\\x18
    sleep 1
    echo
    echo \# Cancelled transfer
else
    cd "$FILE"
    /usr/local/bin/rz -E -e -b
    sleep 1
    echo
    echo
    echo \# Sent \-\> $FILE
fi

vim iterm2-send-zmodem.sh
#!/bin/bash
osascript -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
    /usr/local/bin/sz "$FILE" -e -b
    sleep 1
    echo
    echo \# Received $FILE
fi

​​​​​​

给文件所有权限

chmod 777 iterm2-*

七、工具配置

 

 

 

按照这个图配置

 

配置完重启iTerm 

八、配置完后可能还是不弹窗 可以尝试以下操作

1、配置的的顺序出错 send 在上 recv在下  

2、

如果还是不弹窗可以尝试最后的✅ 勾选到instant 再次尝试 

Logo

更多推荐