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/ .*$//')"
相关推荐
郝学胜-神的一滴7 小时前
Qt 入门 01-02: 开发环境搭建指南
开发语言·c++·qt·客户端
Languorous.7 小时前
C++数据结构高阶|布隆过滤器(Bloom Filter)深度解析:从原理到手写实现,面试高频考点全覆盖
数据结构·c++·面试
山河木马7 小时前
Emscripten 从 C/C++ 调用 JavaScript
前端·javascript·c++
TANGLONG2227 小时前
【C++】继承详解——基类/派生类、作用域、默认函数、菱形继承(超详细)
java·c语言·c++·经验分享·笔记·ajax
小侯不躺平.7 小时前
C++ Boost库【2】 --stringalgo字符串算法
linux·c++·算法
code_whiter7 小时前
C++11(stack和queue)
开发语言·c++
用户805533698038 小时前
现代Qt开发教程(新手篇)2.1——QPainter 绘图基础
c++·qt
计算机安禾8 小时前
【c++面向对象编程】第12篇:继承(二):构造与析构顺序,继承中的构造函数
开发语言·c++
雪度娃娃8 小时前
结构型设计模式——享元模式
c++·设计模式·享元模式
TIEM_698 小时前
C++string|遍历、模拟实现、赋值拷贝现代写法
开发语言·c++