解决mac iterm2 rz sz 无法上传下载问题

mac iterm2 使用rz报一串 

$ rz
?**B0100000023be50ive.**B0100000023be50

第一步,安装brew,如果安装过,就省略

cd /usr/local/Homebrew/Library/Taps/homebrew/

rm -rf homebrew-core

git clone https://github.com/Homebrew/homebrew-core.git

第二步,安装 rz sz命令

brew install lrzsz

第三步,进入/usr/local/bin目录编辑iterm2-recv-zmodem.sh和iterm2-send-zmodem.sh 脚本

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

如果上面命令下载文件失败,就手动vim编辑这两个文件,内容如下

iterm2-recv-zmodem.sh脚本内容如下

#!/bin/bash
# Author: Matt Mastracci ([email protected])
# 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

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

iterm2-send-zmodem.sh 

扫描二维码关注公众号,回复: 14775569 查看本文章
#!/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" --escape --binary --bufsize 4096
	sleep 1
	echo
	echo \# Received $FILE
fi

到此试试rz和sz命令,如果还继续报错,那需要下面的操作。。。。。。。。。。

第四部

添加iTerm2的rz、sz命令trigger

Perference-> Profiles -> Default -> Advanced -> Triggers 的 Edit 按钮

 rz waiting to receive.\*\*B0100

/usr/local/bin/iterm2-send-zmodem.sh

\*\*B00000000000000

/usr/local/bin/iterm2-recv-zmodem.sh

猜你喜欢

转载自blog.csdn.net/monkey_90ge/article/details/127259175