Skip to content

Instantly share code, notes, and snippets.

@strooooke
Created April 29, 2017 11:57
Show Gist options
  • Save strooooke/f814542f5d6d89a82abefc3663c83a3c to your computer and use it in GitHub Desktop.
Save strooooke/f814542f5d6d89a82abefc3663c83a3c to your computer and use it in GitHub Desktop.
Wrapper script for adb commands (and pidcat!) that take a -s device serial argument, allowing to choose between devices
#!/bin/bash
# Prompts for device to use from adb devices -l first; inserts -s parameter.
# No sanitizing, error checking or warranties!
# Use like
# $choose_device adb shell
DEVICES=`adb devices -l | sed 1d`
PS3="Choose device or Ctrl+C to quit: "
IFS=$'\n'
select DEVICE in $DEVICES;
do
unset IFS
read -r DEVICE_ID _ <<< "$DEVICE"
ADB_CMD="$1"
shift
eval "$ADB_CMD -s $DEVICE_ID $@"
break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment