about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Builtins/_kill12
-rw-r--r--Completion/Builtins/_signals36
-rw-r--r--Completion/Builtins/_trap2
-rw-r--r--Completion/User/_killall5
4 files changed, 44 insertions, 11 deletions
diff --git a/Completion/Builtins/_kill b/Completion/Builtins/_kill
index 0fee6dee8..44442ef8f 100644
--- a/Completion/Builtins/_kill
+++ b/Completion/Builtins/_kill
@@ -1,10 +1,6 @@
 #compdef kill
 
-local list expl
-
-if compset -P 1 -; then
-  _wanted -C - expl signal &&
-      compadd "$expl[@]" $signals[1,-3]
-else
-  _alternative -C argument 'jobs:: _jobs' 'processes:: _pids'
-fi
+_alternative \
+    'signals:: _signals -p' \
+    'jobs:: _jobs' \
+    'processes:: _pids'
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
diff --git a/Completion/Builtins/_trap b/Completion/Builtins/_trap
index bbbef1c55..0fc9ec2e4 100644
--- a/Completion/Builtins/_trap
+++ b/Completion/Builtins/_trap
@@ -6,5 +6,5 @@ if [[ CURRENT -eq 2 ]]; then
   compset -q
   _normal
 else
-  _wanted signals expl signal && compadd "$expl[@]" - "$signals[@]"
+  _signals -a
 fi
diff --git a/Completion/User/_killall b/Completion/User/_killall
index ebe02f10c..042b3892a 100644
--- a/Completion/User/_killall
+++ b/Completion/User/_killall
@@ -1,4 +1,5 @@
 #compdef killall
 
-compset -P 1 - && _wanted -C - signals expl signal &&
-    compadd "$expl[@]" $signals[1,-3]
+_alternative \
+    'signals:: _signals -p' \
+    'processes:process:{ compadd "$expl[@]" ${$(ps ho comm 2> /dev/null):#(ps|COMMAND)} }'