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

本文介绍了如何使用Brew在国内进行一键安装,详细步骤包括安装Brew、SSHPass以及通过iTerm2配置SSH文件的上传和下载。通过创建和配置脚本,实现了在iTerm2中使用rz和sz命令进行ZModem文件传输。同时,提供了iTerm2的触发器设置以实现文件接收和发送的自动化。
摘要由CSDN通过智能技术生成
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文件并放入到系统的/usr/local/bin目录中,并给予执行权限(chmod +x /usr/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文件并放入到系统的/usr/local/bin目录中,并给予执行权限(chmod +x /usr/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
配置完成后如下图
在这里插入图片描述
  1. 自此在使用ssh命令登录到服务器后,可以使用rz命令上传文件,sz命令下载文件
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值