mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
Stringify adb completions
Also reindent.
This commit is contained in:
parent
4c798ce3b4
commit
044d45a0ff
1 changed files with 40 additions and 43 deletions
|
@ -11,13 +11,10 @@ end
|
||||||
|
|
||||||
function __fish_adb_get_devices --description 'Run adb devices and parse output'
|
function __fish_adb_get_devices --description 'Run adb devices and parse output'
|
||||||
# This seems reasonably portable for all the platforms adb runs on
|
# This seems reasonably portable for all the platforms adb runs on
|
||||||
set -l count (ps x | grep -c adb)
|
set -l procs (ps -Ao comm= | string match 'adb')
|
||||||
set -l TAB \t
|
|
||||||
# Don't run adb devices unless the server is already started - it takes a while to init
|
# Don't run adb devices unless the server is already started - it takes a while to init
|
||||||
if [ $count -gt 1 ]
|
if set -q procs[1]
|
||||||
# The tail is to strip the header line, the sed is to massage the -l format
|
adb devices -l | string replace -rf '(\S+) +.' '$1'\t | string replace -r \t'.*model:(\S+).*' \t'$1'
|
||||||
# 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/"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,17 +45,17 @@ function __fish_adb_run_command --description 'Runs adb with any -s parameters a
|
||||||
end
|
end
|
||||||
|
|
||||||
# adb returns CRLF (seemingly) so strip CRs
|
# adb returns CRLF (seemingly) so strip CRs
|
||||||
adb $sopt shell $argv | sed s/\r//
|
adb $sopt shell $argv | string replace -a \r ''
|
||||||
end
|
end
|
||||||
|
|
||||||
function __fish_adb_list_packages
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
function __fish_adb_list_uninstallable_packages
|
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
|
# -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
|
end
|
||||||
|
|
||||||
# Generic options, must come before command
|
# Generic options, must come before command
|
||||||
|
|
Loading…
Reference in a new issue