Quantcast
Channel: 碳基体
Viewing all articles
Browse latest Browse all 75

Mac使用rz,sz远程上传或下载文件

$
0
0
SecureCRT有个很便捷的文件上传下载工具sz与rz,我们同样可以把这样的便捷带到mac上,只是稍微有一点点麻烦

第一步:下载并安装iterm2  

地址:http://www.iterm2.com/#/section/downloads

第二步: 下载并安装lrzsz


brew install lrzsz

安装成功后,会在以下路径生成两个可执行文件(具体的路径取决于brew配置,可以用find查找一下)

/usr/local/Cellar/lrzsz/0.12.20/bin/rz

/usr/local/Cellar/lrzsz/0.12.20/bin/sz


建立符号连接

ln -s /usr/local/Cellar/lrzsz/0.12.20/bin/sz /usr/local/bin/sz

ln -s /usr/local/Cellar/lrzsz/0.12.20/bin/rz /usr/local/bin/rz



第三步:下载并安装automatic zmoderm for iTerm2

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

注意黄色字体,需要修改为实际sz与rz的路径

cd /usr/local/bin/

wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-send-zmodem.sh

vim 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



wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-recv-zmodem.sh

vim 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



第四步:编写相应的iTerm2 trigger
iTerm2-Profiles-Open Profiles-Edit Profiles-Advanced-Edit Trigger
如下图所示:
Mac使用rz,sz远程上传或下载文件 - 碳基体 - 碳基体
 
 现在就可以使用iTerm2终端便捷地从远程服务器上上传下载文件了

Viewing all articles
Browse latest Browse all 75

Trending Articles