Add zsh completion for targets in conjunction with -C
authorFraser Cormack <frasercrmck@gmail.com>
Fri, 24 Oct 2014 19:34:06 +0000 (20:34 +0100)
committerFraser Cormack <frasercrmck@gmail.com>
Fri, 24 Oct 2014 19:34:06 +0000 (20:34 +0100)
zsh can now list completions for targets in the directory specified by
the -C option

misc/zsh-completion

index 2fe16fb..af24f89 100644 (file)
 #   . path/to/ninja/misc/zsh-completion
 
 __get_targets() {
-  ninja -t targets 2>/dev/null | while read -r a b; do echo $a | cut -d ':' -f1; done;
+  dir="."
+  if [ -n "${opt_args[-C]}" ];
+  then
+    eval dir="${opt_args[-C]}"
+  fi
+  targets_command="ninja -C \"${dir}\" -t targets"
+  eval ${targets_command} 2>/dev/null | while read -r a b; do echo $a | cut -d ':' -f1; done;
+
 }
 
 __get_tools() {