GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — android-dev-tools/pickdevice.pl at master · stik3nd/android-dev-tools

Expand file tree

/

pickdevice.pl

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
60 lines (45 loc) · 1.35 KB
/

pickdevice.pl

Copy path

File metadata and controls

executable file
·
60 lines (45 loc) · 1.35 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env perl
###############################################################################
##
## Easily manipulate the value of ANDROID_SERIAL by presenting an interactive
## list of currently connected devices.
##
## Designed to be invoked by the shell as:
##
## eval $(pickdevice)
##
###############################################################################
use strict;
use Data::Dumper;
###############################################################################
my @devicesOutput = qx{adb devices};
shift(@devicesOutput) =~ m/^List of devices/i or
die "Unexpected `adb devices' output.\n";
my @devices;
my $defaultChoice;
foreach (@devicesOutput) {
chomp;
next if m/^\s*$/;
my ($serial, $desc) = split /\s+/, $_, 2;
push @devices, { serial => $serial, desc => $desc };
if (!defined($defaultChoice) && $serial !~ m/^emulator/) {
$defaultChoice = $#devices;
}
}
if (@devices == 0) {
die "No devices connected?\n";
}
if (!defined($defaultChoice)) {
$defaultChoice = 0;
}
print STDERR "Pick a device:\n";
for (0 .. $#devices) {
print STDERR "\t", $_, ". ", $devices[$_]->{serial}, "\n";
}
print STDERR "\n";
print STDERR "Which would you like for ANDROID_SERIAL? [$defaultChoice] ";
chomp (my $answer = <STDIN>);
if (length $answer == 0) {
$answer = $defaultChoice;
}
print "export ANDROID_SERIAL=", $devices[$answer]->{serial}, "\n";
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.