Skip to content

Instantly share code, notes, and snippets.

@anthann
Created December 10, 2020 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthann/a442e2c5787af2e3f623a84301f311bd to your computer and use it in GitHub Desktop.
Save anthann/a442e2c5787af2e3f623a84301f311bd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
ROOT=`realpath $(dirname "$BASH_SOURCE")`
cd ${ROOT}
cd ..
devices=($(adb devices | awk '{if($2=="device") print $1}'))
if [ ${#devices[@]} == 0 ]; then
echo "No device found."
exit 1
fi
echo "Devices:"
for i in "${!devices[@]}"; do
echo $i ${devices[$i]}
done
read -p "Select a device[0]:" device_id
if [ -z $device_id ]; then
device_id=0
fi
device=${devices[$device_id]}
if [ -z $device ]; then
echo "Invalid input"
exit 1
fi
echo "Selected device " $device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment