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/ .*$//')"
相关推荐
Dovis(誓平步青云)39 分钟前
探索C++标准模板库(STL):String接口的底层实现(下篇)
开发语言·c++·stl·string
KyollBM1 小时前
【CF】Day75——CF (Div. 2) B (数学 + 贪心) + CF 882 (Div. 2) C (01Trie | 区间最大异或和)
c语言·c++·算法
feiyangqingyun2 小时前
Qt/C++开发监控GB28181系统/取流协议/同时支持udp/tcp被动/tcp主动
c++·qt·udp·gb28181
CV点灯大师2 小时前
C++算法训练营 Day10 栈与队列(1)
c++·redis·算法
成工小白3 小时前
【C++ 】智能指针:内存管理的 “自动导航仪”
开发语言·c++·智能指针
sc写算法3 小时前
基于nlohmann/json 实现 从C++对象转换成JSON数据格式
开发语言·c++·json
SunkingYang3 小时前
C++中如何遍历map?
c++·stl·map·遍历·方法
Andrew_Xzw3 小时前
数据结构与算法(快速基础C++版)
开发语言·数据结构·c++·python·深度学习·算法
库库的里昂3 小时前
【C++从练气到飞升】03---构造函数和析构函数
开发语言·c++
momo卡3 小时前
MinGW-w64的安装详细步骤(c_c++的编译器gcc、g++的windows版,win10、win11真实可用)
c语言·c++·windows