-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadb-im
35 lines (34 loc) · 852 Bytes
/
adb-im
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
ADBBIN=/media/devel/android/sdk/platform-tools/adb
read -r -a DEVS <<< $($ADBBIN devices |grep -v "^List of devices"|awk '{print $1}')
DEVSNR=${#DEVS[@]}
NRREGEX='^[0-9]+$'
if [ $DEVSNR -lt 2 ]
then
$ADBBIN "$@"
else
if [[ $1 == "kill-server" || $1 == "start-server" || $1 == "root" || $1 == "unroot" || $1 == "usb" || $1 == "tcp" || $1 == "help" || $1 == "version" ]]
then
$ADBBIN "$@"
else
printf "\n"
for (( i=0; i<=$(( $DEVSNR -1 )); i++ ))
do
printf "$i - ${DEVS[$i]}\n"
done
printf "\n"
printf "Select a device: "
read INPUT
if ! [[ $INPUT =~ $NRREGEX ]]
then
printf "Bad input\n"
exit 1
elif [[ $INPUT -lt 0 || $INPUT -gt $(( $DEVSNR -1 )) ]]
then
printf "Wrong selection\n"
exit 2
else
$ADBBIN -s ${DEVS[$INPUT]} "$@"
fi
fi
fi