mac iterm2 rz sz 无法上传下载问题

一、问题状况

在mac上使用brew install lrzsz命令安装后,根据网上一些文章的步骤,修改iterm2的Triggers。但是在远程服务器上执行rz命令,想将本地文件上传到服务器时,命令卡住了:

$ rz
?**B0100000023be50ive.**B0100000023be50

二、如何解决

1、安装lrzsz

brew install lrzsz

##至于mac上brew工具没有安装的的,可以提前安装

2、查看lrzsz工具所在路径

brew list lrzsz  

##这一步很关键,因为路径下存在rz、sz两个工具。
term2-send-zmodem.sh和iterm2-recv-zmodem.sh两个脚本只是对这两个工具的简单封装,

3、下载iterm2-zmodem脚本文件: 脚本地址链接

下载解压后,获取到的就是上述提到的term2-send-zmodem.sh和iterm2-recv-zmodem.sh两个脚本

4、修改脚本

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   ##/usr/local/bin/rz这个rz工具路径改为brew list lrzsz 时获取到的路径
	sleep 1
	echo
	echo
	echo \# Sent \-\> $FILE
fi

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    ##/usr/local/bin/rz这个rz工具路径改为brew list lrzsz 时获取到的路径
	sleep 1
	echo
	echo \# Received $FILE
fi

5、修改iterm2的Triggers

iterm2工具上:
Settings> Profiles -> Default -> Advanced -> Triggers 的 Edit 按钮

修改内容:
rz waiting to receive.\*\*B0100
xxx/iterm2-send-zmodem.sh     ##iterm2-send-zmodem.sh的存放路径

\*\*B00000000000000
xxx/iterm2-recv-zmodem.sh    #iterm2-recv-zmodem.sh的存放路径

在这里插入图片描述
至此到远程服务器上,使用rz上传本地文件成功

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要美化mac iTerm2,你可以按照以下步骤进行操作: 1 主题选择:在iTerm2的官方主题库(https://iterm2colorschemes.com/)中选择一个你喜欢的主题。下载主题文件(.itermcolors)到你的电脑上。 2. 安装oh-my-zsh:oh-my-zsh是一个功能强大的终端工具,可以提供丰富的主题和插件。你可以使用以下命令来安装oh-my-zsh: ``` sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ``` 3. 配置zsh主题:在终端中运行以下命令来编辑`~/.zshrc`文件: ``` nano ~/.zshrc ``` 找到并修改`ZSH_THEME`行,将其设置为你喜欢的主题,例如: ``` ZSH_THEME="agnoster" ``` 保存并退出文件。 4. 安装Powerline字体:对于某些主题,你可能需要安装特定的Powerline字体才能正常显示。你可以在GitHub上找到一些流行的Powerline字体,如Powerline Fonts(https://github.com/powerline/fonts)。下载并安装合适的字体,然后在iTerm2的设置中将字体设置为你安装的Powerline字体。 5. 配置iTerm2主题:打开iTerm2,在菜单中选择“Preferences”(偏好设置)。在“Profiles”(配置文件)选项卡中,选择你正在使用的配置文件,并在“Colors”(颜色)选项卡中选择“Color Presets”(颜色预设)。点击右侧的下拉菜单,选择“Import...”(导入),然后导入你下载的主题文件。 6. 其他自定义:除了主题之外,你还可以根据个人喜好进行其他自定义。iTerm2提供了许多选项,如自定义背景图像、透明度、光标样式等。 完成以上步骤后,你的mac iTerm2就会变得更加美化和个性化了!希望对你有帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值