0.brew工具
# 国内可用的一键安装脚本
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
1.sshpass
- 新建sshpass.rb文件,文件内容如下
require 'formula'
class Sshpass < Formula
url 'http://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz'
homepage 'http://sourceforge.net/projects/sshpass'
sha256 'c6324fcee608b99a58f9870157dfa754837f8c48be3df0f5e2f3accf145dee60'
def install
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
def test
system "sshpass"
end
end
- 执行安装
# 文件路径更改为sshpass.rb文件的路径
brew install /Users/jonathan/Downloads/sshpass.rb
2.常用开发命令
brew install git maven node telnet wegt ffmpeg lrzsz
3.iterm2结合lrzsz工具上传下载文件
- 服务端和本地都安装lrzsz工具
- 新建iterm2-recv-zmodem.sh文件并放入到系统的/user/local/bin目录中,并给予执行权限(chmod +x /user/local/bin/iterm2-recv-zmodem.sh)
#!/bin/bash
# 这个脚本来自 github,删掉了一些 ** 言论。
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 -E -e -b --bufsize 4096
sleep 1
echo
echo
echo \# Sent \-\> $FILE
fi
- 新建iterm2-send-zmodem.sh文件并放入到系统的/user/local/bin目录中,并给予执行权限(chmod +x /user/local/bin/iterm2-send-zmodem.sh)
#!/bin/bash
# 这个脚本来自 github,删掉了一些 ** 言论。
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" -e -b
sleep 1
echo
echo \# Received $FILE
fi
4.iterm2>Profiles选中需要配置的Profile,点击右侧顶部Advanced中Triggers栏的Edit按钮
5. 增加两个配置项,内容如下
Regular Expression | Action | Parameters | Instant |
---|---|---|---|
rz waiting to receive.**B0100 | Run Silent Comprocess… | /usr/local/bin/iterm2-send-zmodem.sh | √ |
**B00000000000000 | Run Silent Comprocess… | /usr/local/bin/iterm2-recv-zmodem.sh | √ |
配置完成后如下图
6. 自此在使用ssh命令登录到服务器后,可以使用rz命令上传文件,sz命令下载文件