mac iterm2 rz command installation

Installation configuration

 

install lrzsz

 

Use brew install lrzsz. If the installation encounters errors, use the following methods:

 

curl -k https://ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz -o lrzsz-0.12.20.tar.gz

Put the downloaded file in the ~/Library/Caches/Homebrew directory

 

brew install lrzsz

Save the iterm2-send-zmodem.sh and iterm2-recv-zmodem.sh scripts in /usr/local/bin/ and add the execution permission 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

be

 

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

be

Add Triggers in iTerm 2

 

Open iTerm's Preferences, or use command + , , click the Profiles item, the Advanced item, enter the Tirggers, click Edit, and add two rules:

 

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

At this point, all configurations are complete. Now you can use black technology to transfer files.

 

Instructions

 

Send file to remote server

 

Enter rz on the remote server and press Enter 

Select the file to upload locally 

Waiting for upload 

Download files from remote server

 

Enter sz filename filename1 … filenameN on the remote server

 

Select a local storage directory 

waiting to download 

PS: The remote server also needs to install lrzsz. 

centOS installation method: yum -y install lrzsz

 

existing problems

 

Large files cannot be transferred and will be stuck

 

refer to

 

https://github.com/mmastrac/iterm2-zmodem

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326979212&siteId=291194637