Skip to content

Instantly share code, notes, and snippets.

@ncornette
Created August 6, 2012 08:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ncornette/3272344 to your computer and use it in GitHub Desktop.
Save ncornette/3272344 to your computer and use it in GitHub Desktop.
An interactive Bash function that allow you to select an Android device in a list then Sets ANDROID_SERIAL
# Display a list of all connected Android devices
# Set ANDROID_SERIAL environment from selected item
# Example of use : # adb-setdev && adb install -r myapp.apk
function adb-setdev()
{
devices=($(adb devices|grep "device$"|cut -f1))
devices_count=${#devices[*]}
if [ "$devices_count" -eq "0" ]
then
unset ANDROID_SERIAL
elif [ "$devices_count" -eq "1" ]
then
export ANDROID_SERIAL=$devices
else
# Ask for a device to select
select device in ${devices[*]}
do
export ANDROID_SERIAL=$device
break
done
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment