macOS 下 iTerm 如何安装 rzsz #101

简介: macOS 下 iTerm 如何安装 rzsz #101

自制


安装:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

安装过程中,需要输入密码和确认


如果安装过程中遇到:,则说明你需要代理,设置 代理,$ Git download : error: RPC failed; curl 18 transfer closed with outstanding read data remainingGitHub

$ git config --global https.proxy http://127.0.0.1:端口号

$ git config --global http.proxy http://127.0.0.1:端口号

安装成功:


可以通过 测试是否安装成功$ brew --help

卸载:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"


安装 lrzsz


$ brew install lrzsz

安装完成后,进入$ cd /usr/local/bin


创建文件并添加内容


$ vi iterm2-recv-zmodem.sh
$ vi iterm2-send-zmodem.sh

创建好后,两个文件后分别添加内容

  1. 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
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
  1. 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
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


点击 的设置界面 的 Edit 按钮,加入以下配置:iTerm2Perference-> Profiles -> Default -> Advanced -> Triggers

Regular expression: rz waiting to receive.\*\*B0100
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-send-zmodem.sh
Regular expression: \*\*B00000000000000
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-recv-zmodem.sh


测试


rz 上传功能:在 bash 中,也就是 iTerm2 终端输入 rz 会弹出文件选择框,选择文件 select 就开始上传,会上传到当前目录

sz 下载功能:sz fileName(你要下载的文件的名字) 回车,会弹出窗体,我们选择要保存的地方即可。

目录
相关文章
|
Shell 网络安全 数据安全/隐私保护
Mac OS版的xshell——Mac OS 终端利器iTerm2
Mac OS版的xshell——Mac OS 终端利器iTerm2
14477 1
Mac OS版的xshell——Mac OS 终端利器iTerm2
|
开发工具 iOS开发 MacOS
|
4月前
|
关系型数据库 MySQL 数据库
【Mac os系统】安装MySQL数据库
本文详细介绍了在Mac OS系统上安装MySQL数据库的步骤,包括下载、安装、配置环境变量、启动服务、授权设置以及解决常见问题,并提供了一些常用的MySQL命令。
285 0
【Mac os系统】安装MySQL数据库
|
5月前
|
Linux 虚拟化 iOS开发
部署06--MacOS安装VMware Fusion安装
部署06--MacOS安装VMware Fusion安装
|
4月前
|
测试技术 Linux 虚拟化
iOS自动化测试方案(五):保姆级VMware虚拟机安装MacOS
详细的VMware虚拟机安装macOS Big Sur的保姆级教程,包括下载VMware和macOS镜像、图解安装步骤和遇到问题时的解决方案,旨在帮助读者顺利搭建macOS虚拟机环境。
190 3
iOS自动化测试方案(五):保姆级VMware虚拟机安装MacOS
|
4月前
|
虚拟化 数据安全/隐私保护 iOS开发
VMware——安装MacOS 系统教程(仅供学习交流)
VMware——安装MacOS 系统教程(仅供学习交流)
90 4
|
6月前
|
Java Shell 开发工具
03. 【Java教程】在 MacOS 上安装 Java
03. 【Java教程】在 MacOS 上安装 Java
65 1
|
6月前
|
JavaScript iOS开发 开发者
pnpm的安装与配置(Windows/macOS)
pnpm的安装与配置(Windows/macOS)
1969 0
|
6月前
|
资源调度 JavaScript iOS开发
yarn的安装与配置(Windows/macOS)
yarn的安装与配置(Windows/macOS)
691 0
|
7月前
|
编解码 Oracle iOS开发
VirtualBox虚拟机安装Mac OS X Lion系统详解
VirtualBox虚拟机安装Mac OS X Lion系统详解
340 1