标签:设置 attr shel echo chm homebrew github 令行 unicode
mac os 使用rzsz传输文件
安装brew
brew是Mac OS上的一个包管理工具,可以使用它来安装接下来要使用到的iTerm,wget等工具
Mac默认安装了ruby,打开终端执行如下命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Homebrew安装成功后,会自动创建目录 /usr/local/Cellar 来存放Homebrew安装的程序。 这时就可以在命令行状态下面就可以使用 brew 命令了.
安装iTerm2
iTerm是一个Mac下的终端工具,非常好用的命令行工具。Mac自带的终端是不支持lrzsz的,需要先下载支持它的iterms
安装lrzsz
brew install lrzsz
安装wget
brew install wget
因脚本链接下载不到,只好编辑安装脚本
cd /usr/local/bin
vi 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
vi 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
chmod +x iterm2-recv-zmodem.sh iterm2-send-zmodem.sh
修改iTerm2的default trigger(iTerm偏好设置-> Profiles -> Default -> Advanced -> Triggers的Edit按钮):
Regular expression: \*\*B0100
Action: Run Silent Coprocess
Regular expression: \*\*B00000000000000
Action: Run Silent Coprocess
Parameters: /usr/local/bin/iterm2-recv-zmodem.sh
重启iTerm
标签:设置 attr shel echo chm homebrew github 令行 unicode
原文地址:https://www.cnblogs.com/hankyoon/p/12379889.html