首页 > 其他分享 >mac下使用itrem2时进行rz sz的配置

mac下使用itrem2时进行rz sz的配置

时间:2022-11-17 23:02:11浏览次数:70  
标签:sz iterm2 rz echo x18 application mac FILE tell

1.安装iterm2

官网下载 http://www.iterm2.com/

2.安装homebrew

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

3.安装lrzsz

brew install lrzsz 

4.配置rz sz 进行上传下载

cd /usr/local/bin

新增如下两个文件

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
vim iterm2-send-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 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

5.添加权限

chmod 777 iterm2-*

6.配置iterm2

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

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

 配置成功如下:

标签:sz,iterm2,rz,echo,x18,application,mac,FILE,tell
From: https://www.cnblogs.com/testero/p/16901321.html

相关文章

  • MAC安装NVM
    curl-o-https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh|bash nvm:commandnotfountcd~/.nvmopen.bash_profile###addexportNVM......
  • 五个最好的复制/粘贴的Mac App应用
    ​ 如果你刚用Mac,之前是用Windows电脑的,第一个问题就会发现,Mac上的复制/粘贴找不到了。如果你也有同样的问题,或者你在找Mac上有没有好用的剪贴板管理工具,可以在下面的文......
  • macbook M1安装elasticsearch
    java-version查看java安装是否成功然后安装:brewinstallelastic/tap/elasticsearch-full启动:brewservicesstartelastic/tap/elasticsearch-full浏览器输入:http:/......
  • m1 mac 断流
    参考:https://zhuanlan.zhihu.com/p/441284532Terminal中直接开启关闭AWDLDISABLE:sudoifconfigawdl0downENABLE:sudoifconfigawdl0upifconfig查看是否......
  • 在macbook m1上调试flink1.14.3
    前置条件1:首先先用homebrew安装一下flink1.14.3版本,安装完成后,/usr/local/Celler/apache-flink/1.14.3是主路径。可以看看有没有类似的文件夹来确定有没有安装上。前置条......
  • 【MacOs】Go语言环境搭建
    一、下载安装Go官网下载地址:https://golang.org/dl/Go官方镜像站(推荐):https://golang.google.cn/dl/选择对应的版本:M系列(ARM64)|Inter(x86-64),双击安装,安装后查看: ......
  • 录屏操作软件AutoMacroRecorder使用技巧
    AutoMacroRecorder自动录屏操作软件在www.automacrorecorder.com/下载。安装方式很简单!下一步下一步,不需要多说什么了。1.创建最简单的录屏......
  • Lightroom Classic for mac(Lrc2021) 10.3中文直装版
    Lightroom Classic2021中文版为照片展现出摄影效果最佳一面所需的所有桌面编辑工具,包括提亮颜色、使灰暗的摄影更加生动、删除瑕疵、将弯曲的画面拉直等。您可以在电脑桌......
  • mac elasticsearch could not find java in bundled jdk 官方解决方案
    1.执行 ./bin/elasticsearch 报未找到JDK2.检查java-version 存在  3.exportJAVA_HOME=/usr/bin/java 无效 官方文档https://www.elastic.co/guid......
  • vue cli代理运行在mac平台偶尔请求失败问题
    1.问题Proxyerror:Couldnotproxyrequest/chart/updatefromxxx.xx.xx.xx:xxxxtohttp://xxx.xx.xx.xx:xxxx.Seehttps://nodejs.org/api/errors.html#errors_com......