Mac iTerm 2使用rz、sz从远程上传下载文件
2016-07-14 17:28
453 查看
最近有将本地文件传向服务器的需求,于是从同事那里听来了rz、sz这个黑魔法,迫不及待就安装使用了一下,极其好用。
(PS:不要问为嘛不使用scp,因为种种原因无法使用,而且有了这个之后即使可以使用scp我也不会用了,为嘛?懒!输命令很麻烦!ip记不住更麻烦!)
百度的开发机需要跳两次,所以scp不好使了
将下载的文件放到
至此,所有配置完成。下面就可以使用黑科技来传输文件了。
选择本地要上传的文件
等待上传
从远端服务器下载文件
等待下载
PS:远端服务器也需要安装lrzsz。
centOS安装方法: yum -y install lrzsz
(PS:不要问为嘛不使用scp,因为种种原因无法使用,而且有了这个之后即使可以使用scp我也不会用了,为嘛?懒!输命令很麻烦!ip记不住更麻烦!)
百度的开发机需要跳两次,所以scp不好使了
安装配置
安装lrzsz
使用brew install lrzsz。如果安装遇到错误的话,使用以下方法:
curl -k https://ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz -o lrzsz-0.12.20.tar.gz
将下载的文件放到
~/Library/Caches/Homebrew目录下
brew install lrzsz
将 iterm2-send-zmodem.sh 和 iterm2-recv-zmodem.sh 脚本保存在 /usr/local/bin/
#!/bin/bash # iterm2-recv-zmodem.sh 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 echo \# Received $FILE echo fi
#!/bin/bash # iterm2-send-zmodem.sh 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" echo \# Received $FILE echo fi
在iTerm 2添加Triggers
打开iTerm的Preferences,或者使用 command + , ,点进Profiles项,Advanced项,进入Tirggers,点击Edit,添加两条规则:Regular expression: rz waiting to receive.\*\*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
至此,所有配置完成。下面就可以使用黑科技来传输文件了。
使用方法
将文件传到远端服务器
在远端服务器上输入 rz ,回车选择本地要上传的文件
等待上传
从远端服务器下载文件
在远端服务器输入 sz filename filename1 … filenameN
选择本地的存储目录等待下载
PS:远端服务器也需要安装lrzsz。
centOS安装方法: yum -y install lrzsz
存在的问题
大文件传输不了,会卡住参考
https://github.com/mmastrac/iterm2-zmodem相关文章推荐
- 分布式项目架构DEMO图
- Android事件分发机制分析
- POI导出EXCEL经典实现
- 建立以太坊开发环境
- shell 中变量的截取
- [从头读历史] 第303节 星球战争 起始:冷兵器战争的宏观架构
- Cygwin 完全下载及安装
- 使用split分隔字符串
- atom 阿童木怎么加snippet片段,函数注释
- 多线程基础
- windows上类似dnsmasq的软件dualdhcpdnsserver介绍
- Android中文本字体的问题
- CHAPTER ONE - CHILDHOOD - Abandoned and Chosen
- JS学习笔记(1)
- 转载--Ubuntu设置环境变量
- PAT-乙级-1050. 螺旋矩阵(25)
- .Net默认IE版本号的两种方式
- 几个简单的shell脚本
- property详解(二)
- 批量下载文件