Skip to content

Instantly share code, notes, and snippets.

@romannurik
Created October 16, 2009 07:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romannurik/211627 to your computer and use it in GitHub Desktop.
Save romannurik/211627 to your computer and use it in GitHub Desktop.
#
#
#
# MOVED TO http://code.google.com/p/romannurik-code/source/browse/misc/bash_completion/adb
#
#
#
function _adb()
{
local first=${COMP_WORDS[0]}
local word=${COMP_WORDS[COMP_CWORD]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
local cancelcomp=''
# See if we are looking for a device serial number
if [[ ${prev} == '-s' ]]; then
local devices=$(${first} devices | sed '1d' | cut -f 1 -d " ")
COMPREPLY=($(compgen -W "${devices}" -- "${word}"))
if [[ ${COMPREPLY} == '' ]]; then
COMPREPLY=""
echo
echo 'No devices found. Run "adb devices" for a sanity check.'
cancelcomp=1
fi
fi
if [[ ${COMPREPLY} == '' && ${cancelcomp} != 1 ]]; then
COMPREPLY=($(compgen -f -- "${word}"))
fi
}
complete -F _adb adb
@nschwermann
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment