CulebraTester2-public安装

复制代码
#! /bin/bash
#=====================================================================
# Selects an android device
# Copyright (C) 2012-2022 Diego Torres Milano. All rights reserved.
#
# The simplest way to invoke this script is creating a function like
# this one in your shell startup file:
#
# ```
# adb ()
# {
#    command adb $(android-select-device "$@") "$@"
# }
#
# ```
#
# See:
#    - http://dtmilano.blogspot.ca/2013/01/android-select-device.html
#    - http://dtmilano.blogspot.ca/2012/03/selecting-adb-device.html
# for details on usage.
#=====================================================================

get_adb_devices() {
    command adb $ADB_SERVER devices $LONG 2>&1 | tail -n +2 | sed '/^$/d'
}

git_pull() {
    [[ "$UNAME" == 'Linux' ]] && OPT=-e
    ASD=$(readlink $OPT $0)
    if [[ -n "$ASD" ]]
    then
        DIR=$(dirname $ASD)
        if [[ -n "$DIR" && -d "$DIR/.git" ]]
        then
            (cd $DIR && git pull --no-rebase)
        fi
    fi
}

PROGNAME=$(basename $0)
VERSION="3.6.0"
UNAME=$(uname)
DEVICE_OPT=
LONG=
ADB_SERVER=

git_pull > /dev/null

for ((i=1; i<=$#; ++i))
do
    opt="${@:i:1}"
    case "$opt" in
        -d|-e|-s|-t)
            DEVICE_OPT=$opt
            ;;
        
        -l|--long)
            LONG=-l
            ;;

        start-server|kill-server|connect|pair|devices|-help)
            exit 0
            ;;

        forward)
            if [[ "${@:i+1:1}" == '--list' ]]
            then
                exit 0
            fi
            ;;

        -V|--version)
            echo "$PROGNAME version $VERSION"
            exit 0
            ;;
    esac
done
[ -n "$DEVICE_OPT" ] && exit 0
DEV=$(get_adb_devices)
if [ -z "$DEV" ]
then
    echo "$PROGNAME: ERROR: There's no locally connected devices." >&2
    read -p "Do you want to connect to a remote adb server? [Y/n]: " REPLY
    case "$REPLY" in
        n|N)
            exit 1
            ;;

        y|Y|"")
            read -p "ADB server IP: " IP
            ADB_SERVER="-H $IP"
            DEV=$(get_adb_devices)
            ;;
    esac
elif grep -q 'daemon started successfully' <<<"$DEV"
then
    # try again
    DEV=$(get_adb_devices)
fi
N=$(wc -l <<<"$DEV" | sed 's/ //g')

case "$N" in
1)
    # only one device detected
    D=$DEV
    ;;

*)
    # more than one device detected
    OLDIFS=$IFS
    IFS="
"
    PS3="Select the device to use, <Q> to quit: "
    select D in $DEV
    do
        [ "$REPLY" = 'q' -o "$REPLY" = 'Q' ] && exit 2
        [ -n "$D" ] && break
    done < /dev/tty

    IFS=$OLDIFS
    ;;
esac

if [ -z "$D" ]
then
    echo "$PROGNAME: ERROR: target device couldn't be determined" >&2
    exit 1
fi

# this didn't work on Darwin
# echo "-s ${D%% *}"
printf -- '-s %s\n' "$(echo ${D} | sed 's/ .*$//')"
相关推荐
青少儿编程课堂40 分钟前
用图形化编程做一个“少年探险闯关”小游戏:方向键控制、碰撞检测与多关卡串起完整项目
c++·python·算法·bfs·信息学竞赛
liulilittle1 小时前
长上下文的成本结构与「甜点区间」——从推理引擎的物理约束看 200K/256K/400K
c++·人工智能·ai·llm·注意力·qkv
十五年专注C++开发1 小时前
100w条数据丝滑滚动!Qt Model/View 架构实战(二)
开发语言·c++·qt
skr爱码士1 小时前
06_Qt 常用数据类型与容器:QString、QList、QVector、QMap 的性能与实现分析
开发语言·c++·qt
奶茶树2 小时前
【C++】13. C++11新特性【上】
c语言·开发语言·c++·git·github
wabs6662 小时前
关于栈【力扣1047. 删除字符串中的所有相邻重复项的思考】
数据结构·c++·算法·leetcode··代码随想录
橘色的喵3 小时前
PySide6 工业上位机的实时帧链、零拷贝与跨语言架构
c++·架构·图像·pyside
PTCCTP3 小时前
CSP2024-J T3小木棍
c++
云深处@4 小时前
【C++设计模式】命令模式
c++·设计模式·命令模式
wuminyu4 小时前
JDK21 FFM异步读取MSG_ZEROCOPY错误队列揭秘
java·linux·c语言·jvm·c++