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/ .*$//')"
相关推荐
喜欢吃燃面38 分钟前
C++算法竞赛:位运算
开发语言·c++·学习·算法
草莓熊Lotso41 分钟前
《详解 C++ Date 类的设计与实现:从运算符重载到功能测试》
开发语言·c++·经验分享·笔记·其他
困鲲鲲42 分钟前
CPP多线程2:多线程竞争与死锁问题
c++·多线程·死锁
快乐的划水a9 小时前
组合模式及优化
c++·设计模式·组合模式
星星火柴93611 小时前
关于“双指针法“的总结
数据结构·c++·笔记·学习·算法
艾莉丝努力练剑11 小时前
【洛谷刷题】用C语言和C++做一些入门题,练习洛谷IDE模式:分支机构(一)
c语言·开发语言·数据结构·c++·学习·算法
阿巴~阿巴~14 小时前
深入解析C++ STL链表(List)模拟实现
开发语言·c++·链表·stl·list
旺小仔.15 小时前
双指针和codetop复习
数据结构·c++·算法
jingfeng51415 小时前
C++ STL-string类底层实现
前端·c++·算法
郝学胜-神的一滴15 小时前
基于C++的词法分析器:使用正则表达式的实现
开发语言·c++·程序人生·正则表达式·stl