Skip to content

Instantly share code, notes, and snippets.

Last active November 30, 2023 13:03
  • Star 33 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

This script allows running an adb command (deeplinks, specifically) dynamically - i.e. ask for which device to send a command to if there are multiple devices found. Companion blog post for usage is 🔗 here.

A more flexibile version of this script (that makes it easily reusable for multiple ADB commands) is here.


  • Add instructions for explicit intents when sending the command


  • Filter out unauthorised devices
Copy link

I use fzf to select devices, which can adapt to all adb commands. The code is very simple.

#!/usr/bin/env bash

device_count=$(($(adb devices | wc -l) - 2))

if (( device_count == 1));
    adb $@
elif ((device_count > 1))
    udid=$(adb devices -l | tail -n +2 | awk '{printf "%-20s %-8s\n", $5, $1}' | fzf | awk '{print $2}')
    echo "run adb commond in "$udid
    adb -s $udid $@
    echo "no device"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment