Tab completion for the croot function

Test: bash 3.2
Test: bash 4.4
Change-Id: Ie35ea05c4dd5ea246c005559bb5f36a9c05ef7c4
This commit is contained in:
Anton Hansson 2019-02-04 18:15:39 +00:00
parent 375291fa26
commit ece9c48e4d
1 changed files with 17 additions and 1 deletions

View File

@ -9,7 +9,7 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y
build, and stores those selections in the environment to be read by subsequent
invocations of 'm' etc.
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|arm64|x86_64|mips64] [eng|userdebug|user]
- croot: Changes directory to the top of the tree.
- croot: Changes directory to the top of the tree, or a subdirectory thereof.
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory, but not their dependencies.
- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
@ -370,6 +370,10 @@ function addcompletions()
if should_add_completion bit ; then
complete -C "bit --tab" bit
fi
if [ -z "$ZSH_VERSION" ]; then
# Doesn't work in zsh.
complete -o nospace -F _croot croot
fi
complete -F _lunch lunch
complete -F _complete_android_module_names gomod
@ -985,6 +989,18 @@ function croot()
fi
}
function _croot()
{
local T=$(gettop)
if [ "$T" ]; then
local cur="${COMP_WORDS[COMP_CWORD]}"
k=0
for c in $(compgen -d ${T}/${cur}); do
COMPREPLY[k++]=${c#${T}/}/
done
fi
}
function cproj()
{
local TOPFILE=build/make/core/envsetup.mk