aboutsummaryrefslogtreecommitdiff
path: root/bash_completion/adb
diff options
context:
space:
mode:
Diffstat (limited to 'bash_completion/adb')
-rw-r--r--bash_completion/adb206
1 files changed, 0 insertions, 206 deletions
diff --git a/bash_completion/adb b/bash_completion/adb
deleted file mode 100644
index d1a4c40d0..000000000
--- a/bash_completion/adb
+++ /dev/null
@@ -1,206 +0,0 @@
-#
-# Copyright 2011, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-_adb() {
- local where i cur serial
- COMPREPLY=()
-
- serial="${ANDROID_SERIAL:-none}"
- where=OPTIONS
- for ((i=1; i <= COMP_CWORD; i++)); do \
- cur="${COMP_WORDS[i]}"
- case "${cur}" in
- -s)
- where=OPT_SERIAL
- ;;
- -p)
- where=OPT_PATH
- ;;
- -*)
- where=OPTIONS
- ;;
- *)
- if [[ $where == OPT_SERIAL ]]; then \
- where=OPT_SERIAL_ARG
- elif [[ $where == OPT_SERIAL_ARG ]]; then \
- serial=${cur}
- where=OPTIONS
- else
- where=COMMAND
- break
- fi
- ;;
- esac
- done
-
- if [[ $where == COMMAND && $i -ge $COMP_CWORD ]]; then \
- where=OPTIONS
- fi
-
- OPTIONS="-d -e -s -p"
- COMMAND="devices connect disconnect push pull sync shell emu logcat lolcat forward jdwp install uninstall bugreport help version start-server kill-server get-state get-serialno status-window remount reboot reboot-bootloader root usb tcpip"
-
- case $where in
- OPTIONS|OPT_SERIAL|OPT_PATH)
- COMPREPLY=( $(compgen -W "$OPTIONS $COMMAND" -- "$cur") )
- ;;
- OPT_SERIAL_ARG)
- local devices=$(command adb devices '2>' /dev/null | grep -v "List of devices" | awk '{ print $1 }')
- COMPREPLY=( $(compgen -W "${devices}" -- ${cur}) )
- ;;
- COMMAND)
- if [[ $i -eq $COMP_CWORD ]]; then \
- COMPREPLY=( $(compgen -W "$COMMAND" -- "$cur") )
- else \
- i=$((i+1))
- case "${cur}" in
- shell)
- _adb_cmd_shell "$serial" $i
- ;;
- esac
- fi
- ;;
- esac
-
- return 0
-}
-
-_adb_cmd_shell() {
- local serial IFS=$'\n' i cur
- local -a args
-
- serial=$1
- i=$2
-
- cur="${COMP_WORDS[i]}"
- if [ "$serial" != "none" ]; then \
- args=(-s $serial)
- fi
-
- # There are no filenames we can complete from the filesystem, so disable matching.
- if [[ $(type -t compopt) = "builtin" ]]; then \
- compopt +o filenames +o dirnames +o plusdirs
- fi
-
- if [[ $i -eq $COMP_CWORD && ${cur:0:1} != "/" ]]; then \
- paths=$(command adb ${args[@]} shell echo '$'PATH 2> /dev/null | tr -d '\r' | tr : '\n')
- COMMAND=$(command adb ${args[@]} shell ls $paths '2>' /dev/null | tr -d '\r' | {
- while read -r tmp; do
- command=${tmp##*/}
- printf '%s\n' "$command"
- done
- })
- COMPREPLY=( $(compgen -W "$COMMAND" -- "$cur") )
- return 0
- fi
-
- i=$((i+1))
- case "$cur" in
- ls)
- _adb_shell_ls $serial $i
- ;;
- /*)
- _adb_util_list_files $serial "$cur"
- ;;
- *)
- COMPREPLY=( )
- ;;
- esac
-
- return 0
-}
-
-_adb_shell_ls() {
- local serial i cur file
- local -a args
-
- serial=$1
- i=$2
- if [ "$serial" != "none" ]; then \
- args=(-s $serial)
- fi
-
- where=OPTIONS
- for ((; i <= COMP_CWORD; i++)); do \
- cur="${COMP_WORDS[i]}"
- case "${cur}" in
- -*)
- where=OPTIONS
- ;;
- *)
- where=FILE
- break
- ;;
- esac
- done
-
- file="${COMP_WORDS[COMP_CWORD]}"
- if [[ ${file} == "" ]]; then \
- file="/"
- fi
-
- case $where in
- OPTIONS)
- COMPREPLY=( $(compgen -W "$OPTIONS" -- "$cur") )
- _adb_util_list_files $serial "$file"
- ;;
- FILE)
- _adb_util_list_files $serial "$file"
- ;;
- esac
-
- return 0
-}
-
-_adb_util_list_files() {
- local serial dir IFS=$'\n'
- local -a toks
- local -a args
-
- serial="$1"
- file="$2"
-
- if [ "$serial" != "none" ]; then \
- args=(-s $serial)
- fi
-
- toks=( ${toks[@]-} $(
- command adb ${args[@]} shell ls -dF ${file}"*" '2>' /dev/null | tr -d '\r' | {
- while read -r tmp; do
- filetype=${tmp%% *}
- filename=${tmp:${#filetype}+1}
- if [[ ${filetype:${#filetype}-1:1} == d ]]; then
- printf '%s/\n' "$filename"
- else
- printf '%s\n' "$filename"
- fi
- done
- }
- ))
-
- # Since we're probably doing file completion here, don't add a space after.
- if [[ $(type -t compopt) = "builtin" ]]; then \
- compopt -o nospace
- fi
-
- COMPREPLY=( "${COMPREPLY[@]}" "${toks[@]}" )
-}
-
-if [[ $(type -t compopt) = "builtin" ]]; then \
- complete -F _adb adb
-else \
- complete -o nospace -F _adb adb
-fi