• mac os 使用lrzsz传输文件


    mac os 使用rzsz传输文件

    安装brew
    brew是Mac OS上的一个包管理工具,可以使用它来安装接下来要使用到的iTerm,wget等工具

    Mac默认安装了ruby,打开终端执行如下命令:

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

    Homebrew安装成功后,会自动创建目录 /usr/local/Cellar 来存放Homebrew安装的程序。 这时就可以在命令行状态下面就可以使用 brew 命令了.

    安装iTerm2
    iTerm是一个Mac下的终端工具,非常好用的命令行工具。Mac自带的终端是不支持lrzsz的,需要先下载支持它的iterms

    安装lrzsz

    brew install lrzsz

    安装wget

    brew install wget

    因脚本链接下载不到,只好编辑安装脚本

    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
     
    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
    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
     
    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
    chmod +x iterm2-recv-zmodem.sh iterm2-send-zmodem.sh

    修改iTerm2的default trigger(iTerm偏好设置-> Profiles -> Default -> Advanced -> Triggers的Edit按钮):

    Regular expression: **B0100
    Action: Run Silent Coprocess
    Regular expression: **B00000000000000
    Action: Run Silent Coprocess
    Parameters: /usr/local/bin/iterm2-recv-zmodem.sh

    重启iTerm

  • 相关阅读:
    raid0
    GitHub 标星 11000+,阿里开源的微服务组件如何连续 10 年扛住双十一大促?
    写给大家看的“不负责任” K8s 入门文档
    快速迁移 Next.js 应用到函数计算
    轻松搭建基于 Serverless 的 Go 应用(Gin、Beego 举例)
    阿里巴巴副总裁肖力:云原生安全下看企业新边界——身份管理
    从零开始入门 K8s | K8s 安全之访问控制
    深度解读!阿里统一应用管理架构升级的教训与实践
    CNCF 2019 年度报告重磅发布 | 云原生生态周报 Vol. 41
    HTML+CSS技术实现网页滑动门效果
  • 原文地址:https://www.cnblogs.com/hankyoon/p/12379889.html
Copyright © 2020-2023  润新知