diff options
author | Tommy Nyquist <nyquist@chromium.org> | 2012-10-30 22:28:02 (GMT) |
---|---|---|
committer | Tommy Nyquist <nyquist@chromium.org> | 2012-10-30 22:28:02 (GMT) |
commit | e6c67528e87f2a0899a3edb5e77432d8ec1aceb9 (patch) | |
tree | 32bf7a712da9b6466a85d4c4b4c1b85bb2f7b630 /misc | |
parent | add27262dead9a86ff1da381e736efb85e0cf192 (diff) | |
download | Ninja-e6c67528e87f2a0899a3edb5e77432d8ec1aceb9.zip Ninja-e6c67528e87f2a0899a3edb5e77432d8ec1aceb9.tar.gz Ninja-e6c67528e87f2a0899a3edb5e77432d8ec1aceb9.tar.bz2 |
Add support for reading directory for bash completion.
Currently ninja bash completion only works in the directory where the
build.ninja files is located. This adds support for using the -C
argument to ninja.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/bash-completion | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/misc/bash-completion b/misc/bash-completion index ac4d051..b40136e 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -16,9 +16,17 @@ # . path/to/ninja/misc/bash-completion _ninja_target() { - local cur targets + local cur targets dir line targets_command OPTIND cur="${COMP_WORDS[COMP_CWORD]}" - targets=$((ninja -t targets all 2>/dev/null) | awk -F: '{print $1}') + dir="." + line=$(echo ${COMP_LINE} | cut -d" " -f 2-) + while getopts C: opt "${line[@]}"; do + case $opt in + C) dir="$OPTARG" ;; + esac + done; + targets_command="ninja -C ${dir} -t targets all" + targets=$((${targets_command} 2>/dev/null) | awk -F: '{print $1}') COMPREPLY=($(compgen -W "$targets" -- "$cur")) return 0 } |