diff options
author | Hadi Moshayedi <hadi@moshayedi.net> | 2015-10-31 10:13:33 (GMT) |
---|---|---|
committer | Hadi Moshayedi <hadi@moshayedi.net> | 2015-10-31 10:13:33 (GMT) |
commit | fc135c456d1ba2a39dfb5efe5004102168bef856 (patch) | |
tree | c37ce4267fddcb93dafb3648e5ff01edccaf8dcf /misc/bash-completion | |
parent | 083b6b040681ec3d8ec3cd40f20406b9e6ec8d56 (diff) | |
download | Ninja-fc135c456d1ba2a39dfb5efe5004102168bef856.zip Ninja-fc135c456d1ba2a39dfb5efe5004102168bef856.tar.gz Ninja-fc135c456d1ba2a39dfb5efe5004102168bef856.tar.bz2 |
Speed-up bash target auto-complete.
These speed-ups include:
* Let compgen do the command substitution. Similar to
https://lists.gnu.org/archive/html/bug-bash/2012-03/msg00115.html
* Use "cut" instead of "awk" for separating fields.
Diffstat (limited to 'misc/bash-completion')
-rw-r--r-- | misc/bash-completion | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/misc/bash-completion b/misc/bash-completion index 0536760..e604cd4 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -49,9 +49,8 @@ _ninja_target() { C) eval dir="$OPTARG" ;; esac done; - targets_command="eval ninja -C \"${dir}\" -t targets all" - targets=$(${targets_command} 2>/dev/null | awk -F: '{print $1}') - COMPREPLY=($(compgen -W "$targets" -- "$cur")) + targets_command="eval ninja -C \"${dir}\" -t targets all 2>/dev/null | cut -d: -f1" + COMPREPLY=($(compgen -W '`${targets_command}`' -- "$cur")) fi return } |