Skip to content

Instantly share code, notes, and snippets.

@depau
Created October 8, 2024 20:30
Show Gist options
  • Save depau/4191ae3734ba08267bc6f3851c1f4ec5 to your computer and use it in GitHub Desktop.
Save depau/4191ae3734ba08267bc6f3851c1f4ec5 to your computer and use it in GitHub Desktop.
Wireless ADB autoconnect

Auto-connect to Wireless ADB

The following script discovers available ADB over Wi-Fi devices in the current network and attempts to connect to them.

Installation

For fish

Add it as a fish function: store the following function to ~/.config/fish/functions/adb-autoconnect.fish, it will be loaded automatically:

function adb-autoconnect
    for i in (adb mdns services | tail -n +2 | head -n -1 | cut -f 3 | sort | uniq)
        echo "Connecting $i"
        adb connect $i
    end
end

For other shells

  • Install fish
  • Download the following script and add it to your $PATH
#!/usr/bin/fish
function adb-autoconnect
for i in (adb mdns services | tail -n +2 | head -n -1 | cut -f 3 | sort | uniq)
echo "Connecting $i"
adb connect $i
end
end
adb-autoconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment