如果没有额外的设置,iterm2 使用 rzsz 的时候会卡在
waiting to receive.**B0100000023be50
这个时候就需要使用iterm2提供的trigger来实现rzsz的功能。
第一步:本机安装rzsz
使用rzsz之前本地也需要安装
brew install lrzsz
如果没有安装brew,请先安装brew,mac必备的包管理器!
第二步:创建发送和接收脚本
发送文件的脚本如下,可以复制下面的内容,保存在 /usr/local/bin/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
vim /usr/local/bin/iterm2-send-zmodem.sh
chmod +x /usr/local/bin/iterm2-send-zmodem.sh
接收文件的脚本如下,同样可以复制保存在/usr/local/bin/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
vim /usr/local/bin/iterm2-recv-zmodem.sh<br>chmod +x /usr/local/bin/iterm2-recv-zmodem.sh
第三步:设置Trigger
teigger需要设置两个,一个实发送文件的trigger,一个是接收文件的trigger。
打开iterm2->Preferences->Profiles->Advanced->Triggers
点击Edit,点击+号,几个框分别填入下面的内容
Regular expression: \*\*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
最后设置好结果入如下

每次换电脑都需要设置一遍,记录下来备忘。
你可能还喜欢下面这些文章
在机器太多的时候,我们会使用expect来自动化登录,然而使用expect之后就不能使用rz和sz了。经过一番寻找之后,发现有一个解决方案,在脚本之前增加一个export LC_CTYPE=en_US注意,这个语句放到登录脚本里面就可以了,不要放到.bash_profile里面,如果放到bash_profile里面可能你当前的终端语言都变了,中文可能会乱码。这个缺点是远程机器里面的中文可能会乱码了,如果有更好的解决方案,我会在这里更新。
shell中的if语法是最让我头疼的语法之一,它的判断就向使用USB插头一样——拿起来插入不行,翻转再插入还不行,再翻转插入行了!为了搞清楚这部分语言,我收集了一些文章关于if条件判断的用法,希望对你也有些帮助。一、基本语法if [ command ]; then 符合该条件执行的语句fiif [ command ];then 符合该条件执行的语句elif [ command ];then 符合该条件执行的语句else 符合该条件执行的语句fi语法说明bash shell会按顺序执行if语句,如果command执行后且它的返回状态是0,则会执行符合该条件执行的语
sublime安装插件非常简单。主要方式有两种1.直接安装打开菜单栏里的“Preferences”—>”Browse Packages”,打开包的位置 2.通过Package Control来安装如果没有安装package control,那么可以查看这篇文章:sublime安装package control,让插件安装更简单已经安装package control的,点击菜单栏的“Preferences”–>”Package Control”,或者可以使用快捷键ctrl+shift+p 打开(mac使用cmd+shift+p)。在打开的终端窗口,输入“install