diff --git a/envsetup.sh b/envsetup.sh index a03f02de58..8abf7dc588 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -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 [ ...] [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