Stringify adb completions

Also reindent.
This commit is contained in:
Fabian Homborg 2017-05-03 23:35:34 +02:00
parent 4c798ce3b4
commit 044d45a0ff

View file

@ -11,13 +11,10 @@ end
function __fish_adb_get_devices --description 'Run adb devices and parse output'
# This seems reasonably portable for all the platforms adb runs on
set -l count (ps x | grep -c adb)
set -l TAB \t
set -l procs (ps -Ao comm= | string match 'adb')
# Don't run adb devices unless the server is already started - it takes a while to init
if [ $count -gt 1 ]
# The tail is to strip the header line, the sed is to massage the -l format
# into a simple "identifier <TAB> modelname" format which is what we want for complete
adb devices -l | tail -n +2 | sed -E -e "s/([^ ]+) +./\1$TAB/" -e "s/$TAB.*model:([^ ]+).*/$TAB\1/"
if set -q procs[1]
adb devices -l | string replace -rf '(\S+) +.' '$1'\t | string replace -r \t'.*model:(\S+).*' \t'$1'
end
end
@ -48,17 +45,17 @@ function __fish_adb_run_command --description 'Runs adb with any -s parameters a
end
# adb returns CRLF (seemingly) so strip CRs
adb $sopt shell $argv | sed s/\r//
adb $sopt shell $argv | string replace -a \r ''
end
function __fish_adb_list_packages
__fish_adb_run_command pm list packages ^/dev/null | sed s/package://
__fish_adb_run_command pm list packages ^/dev/null | string replace 'package:' ''
end
function __fish_adb_list_uninstallable_packages
# -3 doesn't exactly mean show uninstallable, but it's the closest you can get to with pm list
__fish_adb_run_command pm list packages -3 | sed s/package://
__fish_adb_run_command pm list packages -3 | string replace 'package:' ''
end
# Generic options, must come before command