首页 > 系统服务 > 详细

mac下使用rz sz的配置

时间:2020-01-13 14:00:17      阅读:102      评论:0      收藏:0      [点我收藏+]
 

系统:mac ox

连接服务器工具:itrem2

1.安装iterm2不做过多介绍

官网下载 http://www.iterm2.com/

2.安装homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3.安装lrzsz

brew install lrzsz  

4.配置rz sz 进行上传下载

cd /usr/local/bin

新增如下两个文件

vi 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
vi 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

5.添加权限

chmod 777 iterm2-*

6.配置iterm2

Perference-> Profiles -> Default -> Advanced -> Triggers 的 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

 配置成功如下:

技术分享图片

mac下使用rz sz的配置

原文:https://www.cnblogs.com/yqrong/p/12186851.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!