Support busybox ps in process completions

Fixes #6918
This commit is contained in:
Johannes Altmanninger 2020-04-19 05:05:16 +02:00
parent 6ab2d78936
commit 9c6e81a838
3 changed files with 11 additions and 3 deletions

View file

@ -5,6 +5,6 @@ function __fish_complete_pids -d "Print a list of process identifiers along with
# Display the tty if available
# But not if it's just question marks, meaning no tty
ps axc -o pid,ucomm,tty | string match -r -v '^\s*'$fish_pid'\s' | tail -n +2 | string replace -r ' *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$' '$1\t$2 [$3]' | string replace -r ' *\[\?*\] *$' ''
__fish_ps -o pid,comm,tty | string match -r -v '^\s*'$fish_pid'\s' | tail -n +2 | string replace -r ' *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$' '$1\t$2 [$3]' | string replace -r ' *\[\?*\] *$' ''
end

View file

@ -1,7 +1,7 @@
function __fish_complete_proc
function __fish_complete_proc --inherit-variable ps
# "comm=" means "print comm field with an empty name", which causes the header to be removed.
# On many systems, comm is truncated (e.g. on Linux it's 15 chars),
# but that's okay since commands that accept them as argument also only use those (e.g. pgrep).
# String removes zombies (ones in parentheses) and padding (macOS adds some apparently).
ps -axc -o comm= | string match -rv '\(.*\)' | string trim
__fish_ps -o comm= | string match -rv '\(.*\)' | string trim
end

View file

@ -0,0 +1,8 @@
function __fish_ps
switch (realpath (command -v ps) | string match -r '[^/]+$')
case busybox
command ps $argv
case '*'
command ps axc $argv
end
end