diff options
author | Taylor Braun-Jones <taylor.braun-jones@ge.com> | 2014-04-25 18:20:42 (GMT) |
---|---|---|
committer | Taylor Braun-Jones <taylor.braun-jones@ge.com> | 2014-04-30 18:37:47 (GMT) |
commit | 4f9ac2aab919f3ce522afe7cc1b65c24897b2306 (patch) | |
tree | 004eca44c490beba8853daec697d6194ac428518 /misc/bash-completion | |
parent | 01ae9ac2583afe263055eed75ca57f2045430a7d (diff) | |
download | Ninja-4f9ac2aab919f3ce522afe7cc1b65c24897b2306.zip Ninja-4f9ac2aab919f3ce522afe7cc1b65c24897b2306.tar.gz Ninja-4f9ac2aab919f3ce522afe7cc1b65c24897b2306.tar.bz2 |
Support completion of arguments to -f and -C options
Note: This is only available for bash_completion users.
Diffstat (limited to 'misc/bash-completion')
-rw-r--r-- | misc/bash-completion | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/misc/bash-completion b/misc/bash-completion index 0ca5235..b30b773 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -16,8 +16,25 @@ # . path/to/ninja/misc/bash-completion _ninja_target() { - local cur targets dir line targets_command OPTIND - cur="${COMP_WORDS[COMP_CWORD]}" + local cur prev targets dir line targets_command OPTIND + + # When available, use bash_completion to: + # 1) Complete words when the cursor is in the middle of the word + # 2) Complete paths with files or directories, as appropriate + if _get_comp_words_by_ref cur prev &>/dev/null ; then + case $prev in + -f) + _filedir + return 0 + ;; + -C) + _filedir -d + return 0 + ;; + esac + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi if [[ "$cur" == "--"* ]]; then # there is currently only one argument that takes -- |