Last active
August 29, 2015 14:01
-
-
Save pardom-zz/01d6cf586fca4d0aeb83 to your computer and use it in GitHub Desktop.
An adb wrapper to select a device by position instead of "-s <serialNumber>"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$#" == "0" ]; then | |
echo "usage: adbs <device> <command>" | |
n=0 | |
while read -r line | |
do | |
if [ "$n" -gt "0" ] && [ -n "$line" ]; then | |
echo "$n: " "$line" | |
else | |
echo "$line" | |
fi | |
n=$((n + 1)) | |
done < <(adb devices -l) | |
exit 1 | |
fi | |
DEVICE=$(adb devices | head -$(($1+1)) | tail -1) | |
ADDRESS=$(echo $DEVICE | cut -d' ' -f 1 | tr -d ' ') | |
shift && adb -s $ADDRESS $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment