/etc/bash_completion.d/adb is in android-tools-adb 4.2.2+git20130529-5.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | ## Bash completion for the Android SDK tools.
##
## Copyright (c) 2009 Matt Brubeck
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
## THE SOFTWARE.
function _adb()
{
local cur prev opts cmds c subcommand device_selected
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-d -e -s -p"
cmds="devices push pull sync shell emu logcat forward jdwp install \
uninstall bugreport help version wait-for-device start-server \
reboot reboot-bootloader sideload \
kill-server get-state get-serialno status-window remount root ppp"
cmds_not_need_device="devices help version start-server kill-server"
subcommand=""
device_selected=""
# Look for the subcommand.
c=1
while [ $c -lt $COMP_CWORD ]; do
word="${COMP_WORDS[c]}"
if [ "$word" = "-d" -o "$word" = "-e" -o "$word" = "-s" ]; then
device_selected=true
opts="-p"
fi
for cmd in $cmds; do
if [ "$cmd" = "$word" ]; then
subcommand="$word"
fi
done
c=$((++c))
done
case "${subcommand}" in
'')
case "${prev}" in
-p)
return 0;
;;
-s)
# Use 'adb devices' to list serial numbers.
COMPREPLY=( $(compgen -W "$(adb devices|grep 'device$'|cut -f1)" -- ${cur} ) )
return 0
;;
esac
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "$opts" -- ${cur}) )
return 0
;;
esac
if [ -z "$device_selected" ]; then
local num_devices=$(( $(adb devices 2>/dev/null|wc -l) - 2 ))
if [ "$num_devices" -gt "1" ]; then
# With multiple devices, you must choose a device first.
COMPREPLY=( $(compgen -W "${opts} ${cmds_not_need_device}" -- ${cur}) )
return 0
fi
fi
COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) )
return 0
;;
install)
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "-l -r -s" -- ${cur}) )
return 0
;;
esac
;;
forward)
# Filename or installation option.
COMPREPLY=( $(compgen -W "tcp: localabstract: localreserved: localfilesystem: dev: jdwp:" -- ${cur}) )
return 0
;;
uninstall)
local apks=$(adb shell ls /data/data 2>/dev/null | tr '\n' ' ' | tr -d '\r')
if [[ $prev != "-k" && $cur == "-" ]]; then
COMPREPLY=( $(compgen -W "-k $apks" -- ${cur}) )
else
COMPREPLY=( $(compgen -W "$apks" -- ${cur}) )
fi
return 0
;;
logcat)
case "${cur}" in
-*)
COMPREPLY=( $(compgen -W "-v -b -c -d -f -g -n -r -s" -- ${cur}) )
return 0
;;
esac
case "${prev}" in
-v)
COMPREPLY=( $(compgen -W "brief process tag thread raw time long" -- ${cur}) )
return 0
;;
-b)
COMPREPLY=( $(compgen -W "radio events main" -- ${cur}) )
return 0
;;
esac
;;
pull)
if [ ${prev} == "pull" ]; then
if [ -z ${cur} ]; then
local files=$(adb shell "ls -a -d /*" 2>/dev/null | tr '\n' ' ' | tr -d '\r')
COMPREPLY=( $(compgen -W "$files" -o filenames -- ${cur}) )
else
local files=$(adb shell "ls -a -d ${cur}*" 2>/dev/null | tr '\n' ' ' | tr -d '\r')
COMPREPLY=( $(compgen -W "$files" -o filenames -- ${cur}) )
fi
return 0
fi
;;
push)
if [ "${COMP_WORDS[COMP_CWORD-2]}" == "push" ]; then
if [ -z "${cur}" ]; then
local files=$(adb shell "ls -a -d /*" 2>/dev/null | tr '\n' ' ' | tr -d '\r')
COMPREPLY=( $(compgen -W "$files" -o filenames -- ${cur}) )
else
local files=$(adb shell "ls -a -d ${cur}*" 2>/dev/null | tr '\n' ' ' | tr -d '\r')
COMPREPLY=( $(compgen -W "$files" -o filenames -- ${cur}) )
fi
return 0
fi
;;
esac
}
complete -o default -F _adb adb
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
|