| 1 |
_lsfd_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
case $prev in |
| 8 |
'-o'|'--output') |
| 9 |
local prefix realcur COLLIST |
| 10 |
realcur="${cur##*,}" |
| 11 |
prefix="${cur%$realcur}" |
| 12 |
COLLIST="$(lsfd --list-columns 2>/dev/null | awk '{print $1}' | tail -n +2)" |
| 13 |
COMPREPLY=( $(compgen -P "$prefix" -W "$COLLIST" -- $realcur) ) |
| 14 |
return 0 |
| 15 |
;; |
| 16 |
'-p'|'--pid') |
| 17 |
COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) ) |
| 18 |
return 0 |
| 19 |
;; |
| 20 |
'-i'|'--inet') |
| 21 |
COMPREPLY=( $(compgen -W "4 6" -- $cur) ) |
| 22 |
return 0 |
| 23 |
;; |
| 24 |
'-Q'|'--filter'|'-C'|'--counter') |
| 25 |
COMPREPLY=( $(compgen -W "expr" -- $cur) ) |
| 26 |
return 0 |
| 27 |
;; |
| 28 |
'--summary') |
| 29 |
COMPREPLY=( $(compgen -W "never only append" -- $cur) ) |
| 30 |
return 0 |
| 31 |
;; |
| 32 |
'--hyperlink') |
| 33 |
COMPREPLY=( $(compgen -W "auto never always" -- $cur) ) |
| 34 |
return 0 |
| 35 |
;; |
| 36 |
'-h'|'--help'|'-V'|'--version'|'-H'|'--list-columns') |
| 37 |
return 0 |
| 38 |
;; |
| 39 |
esac |
| 40 |
case $cur in |
| 41 |
-*) |
| 42 |
OPTS=" |
| 43 |
--noheadings |
| 44 |
--output |
| 45 |
--version |
| 46 |
--help |
| 47 |
--json |
| 48 |
--raw |
| 49 |
--threads |
| 50 |
--notruncate |
| 51 |
--pid |
| 52 |
--inet |
| 53 |
--filter |
| 54 |
--debug-filter |
| 55 |
--summary |
| 56 |
--counter |
| 57 |
--dump-counters |
| 58 |
--list-columns |
| 59 |
--hyperlink |
| 60 |
" |
| 61 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 62 |
return 0 |
| 63 |
;; |
| 64 |
esac |
| 65 |
return 0 |
| 66 |
} |
| 67 |
complete -F _lsfd_module lsfd |