当前位置:首页 > 操作系统 > MacOs

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

0.brew工具

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

1.sshpass

  1. 新建sshpass.rb文件,文件内容如下
<code>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=#{<!---ecms  -->prefix}"
    system "make install"
  end

  def test
    system "sshpass"
  end
end
</code>
  1. 执行安装
<code># 文件路径更改为sshpass.rb文件的路径
brew install /Users/jonathan/Downloads/sshpass.rb
</code>

2.常用开发命令

<code>brew install git maven node telnet wegt ffmpeg lrzsz
</code>

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

  1. 服务端和本地都安装lrzsz工具
  2. 新建iterm2-recv-zmodem.sh文件并放入到系统的/user/local/bin目录中,并给予执行权限(chmod +x /user/local/bin/iterm2-recv-zmodem.sh)
<code>#!/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
</code>
  1. 新建iterm2-send-zmodem.sh文件并放入到系统的/user/local/bin目录中,并给予执行权限(chmod +x /user/local/bin/iterm2-send-zmodem.sh)
<code>#!/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
</code>

4.iterm2>Profiles选中需要配置的Profile,点击右侧顶部Advanced中Triggers栏的Edit按钮
Mac常用开发命令工具 brew sshpass lrzsz 安装&使用 - 文章图片
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

配置完成后如下图
Mac常用开发命令工具 brew sshpass lrzsz 安装&使用 - 文章图片
6. 自此在使用ssh命令登录到服务器后,可以使用rz命令上传文件,sz命令下载文件


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐