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/ .*$//')"
相关推荐
Titan20241 小时前
Linux网络学习:套接字、UDP的封装与应用
linux·服务器·开发语言·网络·c++
Felven2 小时前
C2. Potions (Hard Version)
c++
Tyler_TXZ2 小时前
C++C语言之——树
c语言·c++·算法·
hansang_IR2 小时前
【记录】「COCI 2024/2025」四道模拟赛/8.13
c++·算法
旖旎夜光2 小时前
LeetCode 30:串联所有单词的子串(滑动窗口) —— 题解
数据结构·c++·算法·leetcode·滑动窗口
星恒随风2 小时前
C++ 红黑树封装(二):迭代器、const_iterator 与 operator[] 完整实现 mymap 和 myset
开发语言·c++·状态模式
小小龙学IT3 小时前
oneTBB 开源并行编程库深度解析:从工作窃取调度器到 flow graph 实战
c++·开源
ShineWinsu4 小时前
对于C++:缓冲区管理的详细解析
linux·c++·面试·编程·笔试·io·缓冲区
h_a_o777oah4 小时前
【算法基础】卡特兰数:递推定义与折线对称公式推导及解题策略
c++·算法·acm·组合数学·卡特兰数·反射原理·动态规划dp
帅气的小峰4 小时前
pybind11与nanobind可以共存吗?如何迁移?
c++·python·cuda·推理引擎