Improve kill completions

Use string split instead of cut - which we'd fork for 2*signal
count times in a loop when tab was first pressed. Noticably faster

If giving a signal num, what works everywhere is -NUM, if giving
a signal name, what works everywhere is -s NAME - don't show -sNUM
or -NAME completions; that only works on GNU and it's redundant
anyhow as we show the signal number in the description field for -s
or the signal name for the -NUM case in the pager.

Sort -sNAME completions by the signal number not alphabetical

Shorten descriptions
This commit is contained in:
Aaron Gyes 2020-01-02 22:42:17 -08:00
parent 4ccd33a9d0
commit c1140bc436

View File

@ -1,24 +1,23 @@
__fish_make_completion_signals
for i in $__kill_signals
set number (echo $i | cut -d " " -f 1)
set name (echo $i | cut -d " " -f 2)
for sig in $__kill_signals[-1..1]
set number (string split ' ' $sig)[1]
set name (string split ' ' $sig)[2]
complete -c kill -o $number -d $name
complete -c kill -o $name
complete -c kill -s s -x -a "$number $name"
complete -c kill -k -s s -x -a "$name\t$number"
end
complete -c kill -xa '(__fish_complete_pids)'
if kill -L >/dev/null 2>/dev/null
complete -c kill -s s -l signal -d "Signal to send"
complete -c kill -s l -l list -d "Printf list of signal names, or name of given SIG NUMBER"
complete -c kill -s L -l table -d " Print signal names and their corresponding numbers"
complete -c kill -s a -l all -d "Do not restrict the commandname-to-pid conversion to processes with the same uid as the present process"
complete -c kill -s p -l pid -d "Only print pid of the named processes, do not send any signals"
complete -c kill -s q -l queue -d "Use sigqueue(2) rather than kill(2). The value argument is an integer that is sent along with the signal."
complete -c kill -l verbos -d "Print pid(s) that will be signaled with kill along with the signal."
else # OS X
complete -c kill -s l -l list -d "List signal names"
complete -c kill -s L -l table -d "List signal names and their #s"
complete -c kill -s a -l all -d "Resolve PIDs from other users' too"
complete -c kill -s p -l pid -d "Show resolved PID, don't send signal"
complete -c kill -s q -l queue -d "Use sigqueue(2) rather than kill(2)"
complete -c kill -l verbose -d "Print PIDs and signals sent"
else # non-GNU
complete -c kill -s s -d "Signal to send"
complete -c kill -s l -d "Printf list of signal names, or name of given SIG NUMBER"
end
complete -c kill -s l -d "List signal names"
end