diff options
author | Guilherme Bufolo <guibufolo@gmail.com> | 2013-04-06 11:47:18 (GMT) |
---|---|---|
committer | Guilherme Bufolo <guibufolo@gmail.com> | 2013-04-06 11:47:18 (GMT) |
commit | ca04327e24793348cb84b7a8494718fe5a4881c9 (patch) | |
tree | 31bc89f342097bef85fc3413cdc94c446e2efa48 /misc/bash-completion | |
parent | 372a7a8850a6451dec4f4d2c556878064f2662fb (diff) | |
download | Ninja-ca04327e24793348cb84b7a8494718fe5a4881c9.zip Ninja-ca04327e24793348cb84b7a8494718fe5a4881c9.tar.gz Ninja-ca04327e24793348cb84b7a8494718fe5a4881c9.tar.bz2 |
Improved bash completion when using tools like '-t clean'
Diffstat (limited to 'misc/bash-completion')
-rw-r--r-- | misc/bash-completion | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/misc/bash-completion b/misc/bash-completion index b40136e..2d6975b 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -18,16 +18,23 @@ _ninja_target() { local cur targets dir line targets_command OPTIND cur="${COMP_WORDS[COMP_CWORD]}" - 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 + + if [[ "$cur" == "--"* ]]; then + # there is currently only one argument that takes -- + COMPREPLY=($(compgen -P '--' -W 'version' -- "${cur:2}")) + else + dir="." + line=$(echo ${COMP_LINE} | cut -d" " -f 2-) + # filter out all non relevant arguments but keep C for dirs + while getopts C:f:j:l:k:nvd:t: 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")) + fi + return } complete -F _ninja_target ninja |