600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 转载一片Mac电脑iterm2配置rz sz命令超级实用

转载一片Mac电脑iterm2配置rz sz命令超级实用

时间:2022-11-30 17:31:29

相关推荐

转载一片Mac电脑iterm2配置rz sz命令超级实用

rz 、sz 是什么意思?

rz 即 recv-zmodem,receive zmodem 接收协议(对服务器),对本机表现为上传。sz 即 send-zmodem,send zmodem 发送协议(对服务器),对本机表现为下载。zmodem是一种传输协议(属于SecureCRT),该协议只能可靠地传输大小不超过4GB的文件

核心文件

iterm2-recv-zmodem.sh

#!/bin/bash# Author: Matt Mastracci (matthew@)# AppleScript from /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=iTermif [[ $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 transferelsecd "$FILE"/usr/local/bin/rz -E -e -bsleep 1echoechoecho \# Sent \-\> $FILEfi

iterm2-send-zmodem.sh

#!/bin/bash# Author: Matt Mastracci (matthew@)# AppleScript from /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=iTermif [[ $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)&\"\")"`fiif [[ $FILE = "" ]]; thenecho Cancelled.# Send ZModem cancelecho -e \\x18\\x18\\x18\\x18\\x18sleep 1echoecho \# Cancelled transferelse/usr/local/bin/sz "$FILE" -e -bsleep 1echoecho \# Received $FILEfi

文件存放地址: /usr/local/bin/

开始配置

第一步:安装lrzsz

打开iTerm2 ,输入 brew install lrzsz 安装 lrzsz

第二步:放置文件

打开Finder后,按键command + shift + g 打开快速前往,输入/usr/local/bin进入该文件夹下。

将刚才的两个文件放入该文件夹,需要输入密码输入登录密码即可。

第三步:配置文件权限

打开iTerm2 ,输入 cd /usr/local/bin 进入该目录。再输入chmod 777 iterm2-* 调整文件权限为777。

第四步:软连接执行文件(关键)

新版的brew路径和老版本不同,上面两个文件写死了路径,所以这里使用软连接将文件指向进行调整。

在iTerm2 中输入以下指令:

sudo ln -s /opt/homebrew/bin/rz /usr/local/bin/rz

sudo ln -s /opt/homebrew/bin/sz /usr/local/bin/sz

参考链接

第五步:配置iterm2reference… -> Profiles -> Default -> Advanced -> Edit (in Triggers)

第六步:配置Edit中选项

关键配置步骤!!!

rz对应的选填项

1. Regular expression 中填写rz waiting to receive.\*\*B01002. Action 选择Run Silent Coprocess...3. Parameters 中填写/usr/local/bin/iterm2-send-zmodem.sh4. Instant 不勾选5. Enabled 勾选

sz对应的选填项

1. Regular expression 中填写\*\*B000000000000002. Action 选择Run Silent Coprocess...3. Parameters 中填写/usr/local/bin/iterm2-recv-zmodem.sh4. Instant 不勾选5. Enabled 勾选

配置完成如图:

配完试水,登录远程服务器输入命令rz。。。。超级好用~开心的不要不要滴

内容转载:

原文地址

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。