欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mac下安装配置rz sz

程序员文章站 2024-03-07 17:55:39
...

安装iTerm2

  • 建议去官网下载 http://www.iterm2.com/
  • 下载好后安装即可

安装rz sz

安装rz sz 前的准备 安装brew

一般我们在linux系统上,会使用软件包管理器yum或者apt,而homebrew简称brew,它的功能类似yum或者apt,它是max osx上的软件包管理工具。

  • 安装homebrew 只需要下面一条语句即可
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 安装成功后输入 brew 查看是否有提示信息
MacintoshdeMacBook-Pro:~ caomingge$ brew
Example usage:
  brew search [TEXT|/REGEX/]
  brew info [FORMULA...]
  brew install FORMULA...
  brew update
  brew upgrade [FORMULA...]
  brew uninstall FORMULA...
  brew list [FORMULA...]

Troubleshooting:
  brew config
  brew doctor
  brew install --verbose --debug FORMULA

Contributing:
  brew create [URL [--no-fetch]]
  brew edit [FORMULA...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew
  https://docs.brew.sh
  • 如果看到如上信息,则表示brew安装成功了。

安装 lrzsz

  • 使用如下命令即可
brew install lrzsz

配置rz sz 进行上传下载

  • 进入到/usr/local/bin 目录下
cd /usr/local/bin
  • 在/usr/loal/bin 目录下需要创建两个文件

创建第一个文件

vim iterm2-recv-zmodem.sh

复制以下内容到 iterm2-recv-zmodem.sh

#!/bin/bash
# Author: Matt Mastracci (aaa@qq.com)
# AppleScript from http://*.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

创建第二个文件

vim iterm2-send-zmodem.sh

复制以下内容到 iterm2-send-zmodem.sh

#!/bin/bash
# Author: Matt Mastracci (aaa@qq.com)
# AppleScript from http://*.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 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-*

iTerm2 配置添加rz sz 功能

  • 点击 iTerm2 的设置界面 Perference-> Profiles -> Default -> Advanced -> Triggers 的 Edit 按钮
    Mac下安装配置rz szMac下安装配置rz sz
  • 点击+号,输入下图内容
    Mac下安装配置rz sz点击Close

到此rz sz安装配置就完成了

rz 和 sz 的使用

  • rz 上传功能
    在bash中,也就是iTerm2终端输入rz 就会弹出文件选择框,选择文件 choose 就开始上传,会上传到当前目录。
  • sz 下载功能
    sz fileName(你要下载的文件的名字) 回车。
    会弹出窗体,选择要保存的地方即可。
相关标签: shell