`
dcj3sjt126com
  • 浏览: 1825988 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

mac iterm2 rz命令安装

 
阅读更多

安装配置

 

安装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/  并添加好执行权限  chmod +x iterm2-recv-zmodem.sh

 

 

#!/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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics