Mac rz sz命令
iTerm2使用sz rz進行檔案的上傳下載配置 記錄
一、安裝homebrew
首先確認自己的Mac OSX中是否安裝了homebrew。如果沒有安裝,使用以下命令直接安裝即可:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
二、安裝lrzsz
使用Homebrew安裝lrzsz:
brew install lrzsz
三、配置lrzsz
- 進入/usr/local/bin目錄,建立iterm2-recv-zmodem.sh
- 分別編輯兩個檔案如下:
2.1 vim iterm2-recv-zmodem.sh
檔案內容如下:
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. 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
2.2 vim iterm2-send-zmodem.sh
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.
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
四、修改檔案許可權:
chmod 777 iterm2-*.sh
五、配置iterm2
六、測試
linux連線伺服器:輸入:rz 立刻會有彈框選擇上傳的檔案
sz ***.txt 這個命令需指定要下載至本地的檔案的名稱