Skip to content

Instantly share code, notes, and snippets.

@Yash-Garg
Last active July 4, 2023 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yash-Garg/c74a7a9a13fc63b16d352a34a3b5269b to your computer and use it in GitHub Desktop.
Save Yash-Garg/c74a7a9a13fc63b16d352a34a3b5269b to your computer and use it in GitHub Desktop.
function a {
$totalLines = ((adb devices) | Measure-Object -Line).Lines
$devicesConnected = $totalLines - 1
if ($args -notlike "*-s *" -and $devicesConnected -gt 1) {
$devices = ((adb devices) | Select-Object -Skip 1 | Select-Object -SkipLast 1).Split("`n") | ForEach-Object { $_.Split()[0] }
$devicesText = ""
foreach ($device in $devices) {
$vendor = (adb -s $device shell getprop ro.product.manufacturer).Trim()
$model = (adb -s $device shell getprop ro.product.model).Trim()
$devicesText += "$device - $model ($vendor)`n"
}
$selection = $devicesText | fzf
if (!$selection) {
return
}
$deviceId = $selection.Split()[0]
$Green = [ConsoleColor]::Green
Write-Host "Device Selected: $selection" -ForegroundColor $Green
adb -s $deviceId @args
}
else {
adb @args
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment