iterm2 使用 rz、sz 的方法

如果没有额外的设置,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之后无法使用rz和sz的解决方法

股票获取接口

最近开始研究股票了,自己一个一个的去看,几千支股票完全看不过来啊,想着自己写一个程序,让程序来看股票吧!

股票接口

首先我们需要得到所有的股票代码,好在已经有网页帮我们列出了所有的股票名称和代码,地址是:

http://quote.eastmoney.com/stocklist.html

通过这个页面,就可以抓取了。抓取之后我们就可以存入mysql中,每一个股票可以存一张表,而每一张表中则可以存入股票的动态数据。

这里我们只能获取到一些最简单的数据,一些更加详细的数据还需要获取,这里需要使用一个腾讯财经的接口 (更多…)

一些比较好看的移动端页面

1.比较清新的图文移动端首页 http://huiyi.csdn.net/

2.头条类型的文章  http://geek.csdn.net/

3.起点小说移动站点 http://m.qidian.com/

你可能还喜欢下面这些文章

js保存用户自定义的样式重新载入会闪烁的解决方案

常用js的公共cdn,加速网站

分析评价是好评还是差评的算法

问题引入

一个有经验的网购者能够靠大脑思维能判断一个评价的是好评还是差评,但是一个网购新人却很难分辨的。如果让一个有经验的网购者说出他判断评价的过程,那是否就可以将这种思维用计算机模拟呢?是否也能够精确地判断这个评价到底是隐含着好的评价还是差的评价呢?

评价分类

好的评价

一个好的评价,必定是经过用户使用过后,真实的感受,而在当前网购中,商家往往为了追求好评率而采用现金红包来刺激评价,这样则大大的降低了评价的真实效果。那么有效的评价特征是什么呢? (更多…)

2015年9月,我的博客重新开始

从2011年开始,我便写博客了。今年,一个非常不幸的事情,我的博客被屏蔽了,那一刻的心情我无法形容,但又无可奈何。

于是我又注册了一个域名imhuchao.com,继续我的博客生活。

程序员没有博客,那便如同剑客没有酒,那是何等的寂寥!经历了这些之后,我觉得我应该把博客记录下来。那么起点就设定在今天吧,原来的数据封存起来,不做开放,或许多年之后,我翻开来,轻叹一声,哦,那是2011年我写的东西,真快啊。

好久了,应该快一年没有关注wordpress了,下载安装,再到访问后台,不到一分钟的时间。打开前台一看,哇,竟是如此的清新脱俗!

从未想到她默认的主题变得如此的好看。

(更多…)