diff --git a/share/functions/__fish_complete_pids.fish b/share/functions/__fish_complete_pids.fish index 9036b0559..a9c5547e0 100644 --- a/share/functions/__fish_complete_pids.fish +++ b/share/functions/__fish_complete_pids.fish @@ -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 diff --git a/share/functions/__fish_complete_proc.fish b/share/functions/__fish_complete_proc.fish index 339e41e47..db0474bcd 100644 --- a/share/functions/__fish_complete_proc.fish +++ b/share/functions/__fish_complete_proc.fish @@ -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 diff --git a/share/functions/__fish_ps.fish b/share/functions/__fish_ps.fish new file mode 100644 index 000000000..8abcbe65d --- /dev/null +++ b/share/functions/__fish_ps.fish @@ -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