当前位置: 首页 > news >正文

mac iterm2 使用 lrzsz

前言

mac os 终端不支持使用 rz sz 上传下载文件,本文提供解决方法。

mac 上安装

brew install lrzsz

两个脚本

注意:/usr/local/bin/iterm2-send-zmodem.sh 中的 sz命令路径要和你mac 上 sz 命令路径一致。
/usr/local/bin/iterm2-recv-zmodem.sh 中的 rz 命令路径要和你 mac 上的 rz 命令路径一致。
查看 mac 上 rz 和 sz 命令的路径

$ which rz
/opt/homebrew/bin/rz
$ which sz
/opt/homebrew/bin/sz
cat > /usr/local/bin/iterm2-send-zmodem.sh < EOF
#!/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 domainosascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; thenFILE=`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)&\"\")"`
elseFILE=`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 = "" ]]; thenecho Cancelled.# Send ZModem cancelecho -e \\x18\\x18\\x18\\x18\\x18sleep 1echoecho \# Cancelled transfer
else/opt/homebrew/bin/sz "$FILE" -e -bsleep 1echoecho \# Received $FILE
fi
EOF
cat > /usr/local/bin/iterm2-recv-zmodem.sh  << EOF
#!/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 domainosascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; thenFILE=`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)&\"\")"`
elseFILE=`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)&\"\")"`
fiif [[ $FILE = "" ]]; thenecho Cancelled.# Send ZModem cancelecho -e \\x18\\x18\\x18\\x18\\x18sleep 1echoecho \# Cancelled transfer
elsecd "$FILE"/opt/homebrew/bin/rz -E -e -bsleep 1echoechoecho \# Sent \-\> $FILE
fi
EOF

给脚本赋予权限

sudo chmod 777 /usr/local/bin/iterm2-*

配置 iterm2

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
注意 Action 列有下拉选项框,选择即可。其他列复制粘贴。
在这里插入图片描述
为方便复制

Regular expression: rz waiting to receive.\*\*B0100Action: Run Silent CoprocessParameters: /usr/local/bin/iterm2-send-zmodem.shInstant: checkedRegular expression: \*\*B00000000000000Action: Run Silent CoprocessParameters: /usr/local/bin/iterm2-recv-zmodem.shInstant: checked
http://www.lryc.cn/news/506263.html

相关文章:

  • PostgreSql-学习06-libpq之同步命令处理
  • 简单配置,全面保护:HZERO审计服务让安全触手可及
  • HCIA-Access V2.5_4_1_1路由协议基础_IP路由表
  • Spring IOC 和 AOP的学习笔记
  • 二七(vue2-03)、生命周期四个阶段及八个钩子、工程化开发和脚手架、组件注册、拆分组件
  • [树] 最轻的天平
  • Linux udev介绍使用
  • 单片机:实现节日彩灯(附带源码)
  • 流程引擎Activiti性能优化方案
  • 【爬虫一】python爬虫基础合集一
  • any/all 子查询优化规则的原理与解析 | OceanBase查询优化
  • ECharts 饼图:数据可视化的重要工具
  • 第10章:CSS最佳实践 --[CSS零基础入门]
  • 怎么在idea中创建springboot项目
  • 递归读取指定目录下的文件
  • 【模型压缩】原理及实例
  • 常用的JVM启动参数有哪些?
  • Curvelet 变换与FDCT
  • Django Admin 管理工具
  • Android笔记【19】
  • 矩阵在资产收益(Asset Returns)中的应用:以资产回报矩阵为例(中英双语)
  • Docker 中如何限制CPU和内存的使用 ?
  • 【AIGC-ChatGPT进阶提示词-《动图生成》】怪物工厂:融合想象力与创造力的奇幻世界
  • docker 使用 xz save 镜像
  • C#经典算法面试题
  • vulnhub靶场【DriftingBlues】之9 final
  • 有124个叶子节点的,完全二叉树最多有多少个节点
  • 从RNN到Transformer:生成式AI自回归模型的全面剖析
  • Java爬虫大冒险:如何征服1688商品搜索之巅
  • 基于Spring Boot的无可购物网站系统