2013-03-24 12:10:55 -05:00
|
|
|
_ionice_module()
|
|
|
|
{
|
|
|
|
local cur prev OPTS
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
case $prev in
|
|
|
|
'-c'|'--class')
|
2013-04-07 03:12:05 -05:00
|
|
|
COMPREPLY=( $(compgen -W "{0..3} none realtime best-effort idle" -- $cur) )
|
2013-03-24 12:10:55 -05:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
'-n'|'--classdata')
|
2013-04-07 03:12:05 -05:00
|
|
|
COMPREPLY=( $(compgen -W "{0..7}" -- $cur) )
|
2013-03-24 12:10:55 -05:00
|
|
|
return 0
|
|
|
|
;;
|
2017-04-11 15:50:09 -05:00
|
|
|
'-P'|'--pgid')
|
|
|
|
local PGID
|
|
|
|
PGID="$(awk '{print $5}' /proc/*/stat 2>/dev/null | sort -u)"
|
|
|
|
COMPREPLY=( $(compgen -W "$PGID" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
2013-03-24 12:10:55 -05:00
|
|
|
'-p'|'--pid')
|
|
|
|
local PIDS
|
|
|
|
PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
|
|
|
|
COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
2017-04-11 15:50:09 -05:00
|
|
|
'-u'|'--uid')
|
|
|
|
local UIDS
|
|
|
|
UIDS="$(stat --format='%u' /proc/[0-9]* | sort -u)"
|
|
|
|
COMPREPLY=( $(compgen -W "$UIDS" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
2013-04-07 03:12:04 -05:00
|
|
|
'-h'|'--help'|'-V'|'--version')
|
|
|
|
return 0
|
|
|
|
;;
|
2013-03-24 12:10:55 -05:00
|
|
|
esac
|
|
|
|
case $cur in
|
|
|
|
-*)
|
2017-04-11 15:50:09 -05:00
|
|
|
OPTS="--class --classdata --pid --pgid --ignore --uid --version --help"
|
2013-03-24 12:10:55 -05:00
|
|
|
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2013-09-30 08:49:00 -05:00
|
|
|
local IFS=$'\n'
|
2013-03-24 12:10:55 -05:00
|
|
|
compopt -o filenames
|
|
|
|
COMPREPLY=( $(compgen -f -- $cur) )
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
complete -F _ionice_module ionice
|