微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Mac常用开发命令工具 brew sshpass lrzsz 安装&使用

0.brew工具

# 国内可用的一键安装脚本 
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

1.sshpass

  1. 新建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
  1. 执行安装
# 文件路径更改为sshpass.rb文件的路径
brew install /Users/jonathan/Downloads/sshpass.rb

2.常用开发命令

brew install git maven node telnet wegt ffmpeg lrzsz

3.iterm2结合lrzsz工具上传下载文件

  1. 服务端和本地都安装lrzsz工具
  2. 新建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
  1. 新建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 ExpressionActionParametersInstant
rz waiting to receive.**B0100Run Silent Comprocess…/usr/local/bin/iterm2-send-zmodem.sh
**B00000000000000Run Silent Comprocess…/usr/local/bin/iterm2-recv-zmodem.sh

配置完成后如下图

在这里插入图片描述

6. 自此在使用ssh命令登录到服务器后,可以使用rz命令上传文件,sz命令下载文件

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐