iterm2 macOS Catalina sz 插件问题解决

升级macOS Catalina beta版本 突然发现登录服务无法使用sz 下载服务文件到本地?错误如下

Sent -> /Users/apus/Documents:/

很是奇怪明明选择的是文件没有问题,怀疑新版系统计划使用zsh替换bash的原因,接口有所变动,iterm2的插件获取FILE文件地址多出两个字符,故修改iterm2-zmodem的接收的脚本如下删除多余的字符 ':/',问题解决,亲测可以下载文件。没有根据系统版本兼容以前的系统请注意

#!/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
    #echo "string : [${FILE}]"
    # mac catalina beta bug fix,delete '/Users/apus/Documents:/' ':/'
    lenNum=${#FILE}
    lengthxx=`expr $lenNum - 2 `
    FILEX=${FILE:0:${lengthxx}}
    cd "$FILEX"
    /usr/local/bin/rz -E -e -b --bufsize 4096
    sleep 1
    echo
    echo
    echo \# Sent \-\> $FILEX
fi

你可能感兴趣的:(iterm2 macOS Catalina sz 插件问题解决)