Mac rz sz命令

iTerm2使用sz rz进行文件的上传下载配置 记录
一、安装homebrew
首先确认自己的Mac OSX中是否安装了homebrew。如果没有安装,使用以下命令直接安装即可:

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

二、安装lrzsz
使用Homebrew安装lrzsz:

brew install lrzsz

三、配置lrzsz

  1. 进入/usr/local/bin目录,创建iterm2-recv-zmodem.shiterm2-send-zmodem.sh
  2. 分别编辑两个文件如下:
    2.1 vim iterm2-recv-zmodem.sh
    文件内容如下:

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.

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

2.2 vim iterm2-send-zmodem.sh

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.
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-*.sh
五、配置iterm2
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

六、测试
linux连接服务器:输入:rz 立刻会有弹框选择上传的文件
sz ***.txt 这个命令需指定要下载至本地的文件的名称

猜你喜欢

转载自blog.csdn.net/xiaojiayudst/article/details/85002121