macOS 安装lrzsz

2022-09-09 20:58:58 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

mac自带的终端是不支持lrzsz的,需要下载安装iterm2

Mac OS 终端利器 iTerm2

安装homebrew

brew的MAC安装

macOS 安装lrzsz

进入/usr/local/bin

由于原作者下架了项目,我们只能手动新建脚本了,下面请无脑全部复制即可。

1.创建iterm2-recv-zmodem.sh

代码语言:javascript复制
#!/bin/bash

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
	sleep 1
	echo
	echo
	echo # Sent -> $FILE
fi

2.创建iterm2-send-zmodem.sh

代码语言:javascript复制
#!/bin/bash

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

3.增加刚才新建的两个文件的权限

代码语言:javascript复制
chmod  x iterm2-send-zmodem.sh 
chmod  x iterm2-recv-zmodem.sh 

4.设置item2

步骤:command “,” 组合键打开item2的“Preferences”面板->Profiles选项卡->Advanced->Triggers(点击Edit即可)

代码语言:javascript复制
Regular expression: **B0100
    Action: Run Silent Coprocess
    Parameters: /usr/local/bin/iterm2-send-zmodem.sh
Regular expression: **B00000000000000
    Action: Run Silent Coprocess
    Parameters: /usr/local/bin/iterm2-recv-zmodem.sh

勾选了 instant就不需要重启items了,然后就可以愉快的传输文件了。

现在就有弹窗了哦~

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/152479.html原文链接:https://javaforall.cn

0 人点赞