在iTerm2中使用Zmodem的方法
2015-07-10 20:16
316 查看
原文地址:http://openexz.sinaapp.com/2012/08/29/%E5%9C%A8iterm2%E4%B8%AD%E4%BD%BF%E7%94%A8zmodem%E7%9A%84%E6%96%B9%E6%B3%95/
iTerm通过trigger的方式可以使用sz、rz命令方便的通过Terminal在远程主机文件传输。
首先需要安装iTerm Build 1.0.0.20120724以上版本,因为从这个版本开始支持trigger。
然后使用port安装sz、rz:
通过链接中“iterm2-zmodem”的说明,分别把iterm2-recv-zmodem.sh、iterm2-send-zmodem.sh放到/usr/local/bin/下,并加上可执行权限。
这里需要做一点小改动,脚本本身需要执行mac的sz、rz,port安装后是在/opt/local/bin/下,而作者的是/usr/local/bin/下,这里需要手动修改一下。
这是修改后的:
iterm2-recv-zmodem.sh
iterm2-send-zmodem.sh
修改iTerm2的default trigger(iTerm偏好设置-> Profiles -> Default -> Advanced -> Triggers的Edit按钮):
iTerm通过trigger的方式可以使用sz、rz命令方便的通过Terminal在远程主机文件传输。
设置方法
首先需要安装iTerm Build 1.0.0.20120724以上版本,因为从这个版本开始支持trigger。然后使用port安装sz、rz:
1 | $ sudo port install lrzsz |
这里需要做一点小改动,脚本本身需要执行mac的sz、rz,port安装后是在/opt/local/bin/下,而作者的是/usr/local/bin/下,这里需要手动修改一下。
这是修改后的:
iterm2-recv-zmodem.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #!/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 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)&\"\")"` if [[ $FILE = "" ]]; then echo Cancelled. # Send ZModem cancel echo -e \\x18\\x18\\x18\\x18\\x18 echo \# Cancelled transfer echo else echo $FILE cd "$FILE" #/usr/local/bin/rz /opt/local/bin/rz echo \# Received $FILE echo fi |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/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 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)&\"\")"` if [[ $FILE = "" ]]; then echo Cancelled. # Send ZModem cancel echo -e \\x18\\x18\\x18\\x18\\x18 echo \# Cancelled transfer echo else echo $FILE #/usr/local/bin/sz "$FILE" /opt/local/bin/sz "$FILE" echo \# Received $FILE echo fi |
1 2 3 4 5 6 7 | 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 |
相关文章推荐
- 第6章 马尔可夫法(PageRank的孩子) 实例和程序
- 【转】IBatis.Net项目数据库SqlServer迁移至Oracle
- 写sql语句连接的时候注意的一个小细节
- 自学笔记C语言复习2015年7月10日
- RPC原理
- 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ...
- HDU 1044 Collect More Jewels(BFS+DFS)
- ZXing 4.7.4 编译的问题
- 制作PPT时,可能这些小习惯你需要注意
- jquery 对 Json 的各种遍历
- 获取一个想要的指定文件的集合,获取文件夹下(包含子目录的所有.java的文件对象,并存储到集合中)
- 不兼容结构的协调——适配器模式(三)
- 如何做好div+css的浏览器兼容性
- 如何做好div+css的浏览器兼容性
- s3c2440裸板程序四个led轮流灭
- linux用户权限管理, chmod, ln
- java基础第三天
- poj3311 Hie with the Pie
- 传感器学习案例 之 公交防盗
- How to use pylab to plot figure()?