| 1 |
_lsns_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS LSNS_COLS_ALL |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
LSNS_COLS_ALL=" |
| 8 |
NS TYPE PATH NPROCS PID PPID COMMAND UID USER |
| 9 |
" |
| 10 |
case $prev in |
| 11 |
'-o'|'--output') |
| 12 |
local prefix realcur LSNS_COLS |
| 13 |
realcur="${cur##*,}" |
| 14 |
prefix="${cur%$realcur}" |
| 15 |
for WORD in $LSNS_COLS_ALL; do |
| 16 |
if ! [[ $prefix == *"$WORD"* ]]; then |
| 17 |
LSNS_COLS="$WORD ${LSNS_COLS:-""}" |
| 18 |
fi |
| 19 |
done |
| 20 |
compopt -o nospace |
| 21 |
COMPREPLY=( $(compgen -P "$prefix" -W "$LSNS_COLS" -S ',' -- $realcur) ) |
| 22 |
return 0 |
| 23 |
;; |
| 24 |
'-p'|'--task') |
| 25 |
COMPREPLY=( $(compgen -W "$(builtin cd /proc && echo [0-9]*)" -- $cur) ) |
| 26 |
return 0 |
| 27 |
;; |
| 28 |
'-t'|'--type') |
| 29 |
COMPREPLY=( $(compgen -W "mnt net ipc user pid uts cgroup time" -- $cur) ) |
| 30 |
return 0 |
| 31 |
;; |
| 32 |
'-H'|'-h'|'--help'|'-V'|'--version') |
| 33 |
return 0 |
| 34 |
;; |
| 35 |
esac |
| 36 |
case $cur in |
| 37 |
-*) |
| 38 |
COMPREPLY=( $(compgen -W " |
| 39 |
--list-columns |
| 40 |
--filter |
| 41 |
--json |
| 42 |
--list |
| 43 |
--noheadings |
| 44 |
--output |
| 45 |
--output-all |
| 46 |
--persistent |
| 47 |
--task |
| 48 |
--raw |
| 49 |
--notruncate |
| 50 |
--nowrap |
| 51 |
--type |
| 52 |
--tree |
| 53 |
--list-columns |
| 54 |
--help |
| 55 |
--version |
| 56 |
" -- $cur) ) |
| 57 |
return 0 |
| 58 |
;; |
| 59 |
esac |
| 60 |
return 0 |
| 61 |
} |
| 62 |
complete -F _lsns_module lsns |