From dfd1b4f8dfe977016bfe0ecd0fc360a526252827 Mon Sep 17 00:00:00 2001 From: Muhannad Fakhouri Date: Sun, 17 Feb 2019 23:10:17 +0100 Subject: [PATCH] adb: improve `adb -s` completion to show helpful info (#7532) Currently it shows for example the following: DEVICE_ID -- transport_id:2 which doesn't really ease device selection. I've adapted the awk script to print device name with it's model name, see the example below: DEVICE_ID -- Pixel_3(blueline) --- plugins/adb/_adb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/adb/_adb b/plugins/adb/_adb index e3c20d751..78c457746 100644 --- a/plugins/adb/_adb +++ b/plugins/adb/_adb @@ -49,7 +49,12 @@ _arguments \ case "$state" in specify_device) _values -C 'devices' ${$(adb devices -l|awk 'NR>1&& $1 \ - {sub(/ +/," ",$0);gsub(":","\\:",$1); printf "%s[%s] ",$1, $NF}'):-""} + {sub(/ +/," ",$0); \ + gsub(":","\\:",$1); \ + for(i=1;i<=NF;i++) { + if($i ~ /model:/) { split($i,m,":") } \ + else if($i ~ /product:/) { split($i,p,":") } } \ + printf "%s[%s(%s)] ",$1, p[2], m[2]}'):-""} return ;; esac @@ -59,4 +64,4 @@ if (( CURRENT == 1 )); then return fi -_files \ No newline at end of file +_files