2013-04-01 17:49:02 +00:00
|
|
|
function __fish_make_completion_signals --description 'Make list of kill signals for completion'
|
2016-07-05 03:28:21 +00:00
|
|
|
set -q __kill_signals
|
|
|
|
and return 0
|
2011-09-23 08:24:21 +00:00
|
|
|
|
2017-08-05 01:02:24 +00:00
|
|
|
set -g __kill_signals
|
|
|
|
|
2016-07-05 03:28:21 +00:00
|
|
|
# Some systems use the GNU coreutils kill command where `kill -L` produces an extended table
|
|
|
|
# format that looks like this:
|
|
|
|
#
|
|
|
|
# 1 HUP Hangup: 1
|
|
|
|
# 2 INT Interrupt: 2
|
|
|
|
#
|
|
|
|
# The procps `kill -L` produces a more compact table. We can distinguish the two cases by
|
|
|
|
# testing whether it supports `kill -t`; in which case it is the coreutils `kill` command.
|
2016-07-10 00:44:21 +00:00
|
|
|
# Darwin doesn't have kill -t or kill -L
|
2018-04-01 20:42:38 +00:00
|
|
|
if kill -t 2>/dev/null >/dev/null
|
|
|
|
or not kill -L 2>/dev/null >/dev/null
|
2016-07-05 03:28:21 +00:00
|
|
|
# Posix systems print out the name of a signal using 'kill -l SIGNUM'.
|
|
|
|
complete -c kill -s l --description "List names of available signals"
|
|
|
|
for i in (seq 31)
|
2017-08-05 01:02:24 +00:00
|
|
|
set -a __kill_signals $i" "(kill -l $i | tr '[:lower:]' '[:upper:]')
|
2016-07-05 03:28:21 +00:00
|
|
|
end
|
|
|
|
else
|
2012-11-18 10:23:22 +00:00
|
|
|
# Debian and some related systems use 'kill -L' to write out a numbered list
|
2011-09-23 08:24:21 +00:00
|
|
|
# of signals. Use this to complete on both number _and_ on signal name.
|
|
|
|
complete -c kill -s L --description "List codes and names of available signals"
|
2016-07-05 03:28:21 +00:00
|
|
|
kill -L | sed -e 's/^ //; s/ */ /g; y/ /\n/' | while read -l signo
|
|
|
|
test -z "$signo"
|
2016-11-28 05:27:22 +00:00
|
|
|
and break # the sed above produces one blank line at the end
|
2016-07-05 03:28:21 +00:00
|
|
|
read -l signame
|
2017-08-05 01:02:24 +00:00
|
|
|
set -a __kill_signals "$signo $signame"
|
2011-09-23 08:24:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|