linux服務(wù)器上安裝了rz、sz钞钙,本地也安裝好相應(yīng)工具和配置觸發(fā)即可。
原文鏈接:https://blog.csdn.net/ccor2002/article/details/105458152/
1.安裝rz声离、sz
brew install lrzsz
2.配置iterm2觸發(fā)器
在/usr/local/bin/
下創(chuàng)建腳本iterm2-send-zmodem.sh
與iterm2-recv-zmodem.sh
-
iterm2-send-zmodem.sh
內(nèi)容如下:
#!/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" --escape --binary --bufsize 4096
sleep 1
echo
echo \# Received "$FILE"
fi
-
iterm2-recv-zmodem.sh
內(nèi)容如下:
#!/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 --rename --escape --binary --bufsize 4096
sleep 1
echo
echo
echo \# Sent \-\> $FILE
fi
3.賦予兩個(gè)腳本執(zhí)行權(quán)限
chmod +x iterm2-recv-zmodem.sh
chmod +x iterm2-send-zmodem.sh
4.在iterm2中配置兩條觸發(fā)規(guī)則
iTerm2 -> Preferences -> Profiles -> Default -> Advanced-> Triggers下的Edit按鈕
Regular expression: rz waiting to receive.\*\*B0100
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-send-zmodem.sh
Instant: checked
Regular expression: \*\*B00000000000000
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-recv-zmodem.sh
Instant: checked
配置效果.png
配置完了芒炼,新開(kāi)一個(gè)iTerm2的窗口就可以試試執(zhí)行rz,看能不能彈出選擇文件窗口术徊,如果可以就配置好了焕议。
5.安裝zssh(Zmodem SSH)
zssh(Zmodem SSH)是一個(gè)程序,用于在使用安全外殼(ssh)時(shí)以交互方式將文件傳輸?shù)竭h(yuǎn)程計(jì)算機(jī)弧关。它旨在作為scp的便捷替代方法盅安,允許您無(wú)需打開(kāi)另一個(gè)會(huì)話并重新進(jìn)行身份驗(yàn)證即可傳輸文件。
brew install zssh
上傳文件
登錄到服務(wù)器后世囊,輸入rz就會(huì)自動(dòng)彈出選擇文件對(duì)話框了别瞭,選擇后確定開(kāi)始上傳傳輸。下載文件
登錄到服務(wù)器后株憾,輸入sz filename 就會(huì)自動(dòng)彈出選擇路徑對(duì)話框了蝙寨,選擇后確定開(kāi)始下載傳輸。