summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Completion/Builtins/_signals36
1 files changed, 36 insertions, 0 deletions
diff --git a/Completion/Builtins/_signals b/Completion/Builtins/_signals
new file mode 100644
index 000000000..c79350044
--- /dev/null
+++ b/Completion/Builtins/_signals
@@ -0,0 +1,36 @@
+#autoload
+
+# Options (only in separate words):
+#
+# -a  use all signals (even the pseudo-signals)
+# -p  needs a `-' prefix
+#
+# A `-' or `--' as the first argument is ignored.
+
+local expl last=-3 minus
+
+while [[ "$1" = -[ap] ]]; do
+  if [[ "$1" = -a ]]; then
+    last=-1
+  else
+    minus=-
+  fi
+  shift
+done
+
+[[ "$1" = -(|-) ]] && shift
+
+if _wanted signals expl signal &&
+       { [[ -z "$minus" ]] || ! _style signals prefix-needed ||
+         [[ "$PREFIX" = -* ]] } ; then
+  local disp tmp
+
+  if _style signals prefix-hidden; then
+    tmp=( "${(@)signals[1,last]}" )
+    disp=(-d tmp)
+  else
+    disp=()
+  fi
+  compadd "$@" "$expl[@]" "$disp[@]" -M 'm:{a-z}=${A-Z}' - \
+          "${minus}${(@)^signals[1,last]}"
+fi