Install LRZSZ

  • Use the following command
brew install lrzsz
Copy the code

Configure rZ SZ for uploading and downloading

In order to upload and download using RZ and SZ we need to do some configuration

  • Into the/usr/local/bindirectory
CD/usr/local/binCopy the code
  • This directory requires two configuration files, which can be pasted or downloaded from Github.
    1. Github: github.com/mmastrac/i….
    2. If you can’t download it, open the file on Github and create two files yourself and paste the contents in

1. Create two files in the /usr/loal/bin directory

iterm2-recv-zmodem.sh
iterm2-send-zmodem.sh
Copy the code

After creating the two files, add the following contents:

  1. iterm2-recv-zmodem.sh
#! /bin/bash
# Author: Matt Mastracci ([email protected])
# 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 domainosascript -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 fiCopy the code
  1. iterm2-send-zmodem.sh
#! /bin/bash
# Author: Matt Mastracci ([email protected])
# 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 domainosascript -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 fiCopy the code

After the file is written and saved, run the following command to add permissions

chmod 777 iterm2-*
Copy the code

After configuring the configuration file, configure iTerm2

ITerm2 configuration adds RZ sZ function

Click the Edit button triggering from the Settings page of iTerm2 Perference-> Profiles -> Default -> Advanced -> Triggers

The configuration is as follows:

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
Copy the code

Rz upload function

  • In Bash, the iTerm2 terminal type Rz and the file selection box pops up. Select the file Choose and upload it to the current directory

Sz download function

  • Sz fileName(the name of the file you want to download) Enter enter
  • It’ll pop up and we’ll just choose where we want to save it.