| 1 |
_coresched_module() |
| 2 |
{ |
| 3 |
compopt -o nosort |
| 4 |
|
| 5 |
COMPREPLY=() |
| 6 |
|
| 7 |
# If the previous argument equals the program name |
| 8 |
if [[ "$1" == "$3" ]]; then |
| 9 |
COMPREPLY=( $(compgen -W "get new copy --help --version" -- "$2") ) |
| 10 |
return 0 |
| 11 |
fi |
| 12 |
|
| 13 |
case $3 in |
| 14 |
"-s"|"--source"|"-d"|"--dest") |
| 15 |
local pids sorted_pids |
| 16 |
pids=$(builtin cd /proc && echo [0-9]*) |
| 17 |
sorted_pids=$(echo "${pids[@]}" | command tr ' ' '\n' | command sort -nr | command tr '\n' ' ') |
| 18 |
COMPREPLY=( $(compgen -W "$sorted_pids" -- "$2") ) |
| 19 |
return 0 |
| 20 |
;; |
| 21 |
"-t"|"--dest-type") |
| 22 |
COMPREPLY=( $(compgen -W "pid tgid pgid" -- "$2") ) |
| 23 |
return 0 |
| 24 |
;; |
| 25 |
"--") |
| 26 |
COMPREPLY=( $(compgen -c "$2") ) |
| 27 |
return 0 |
| 28 |
;; |
| 29 |
esac |
| 30 |
|
| 31 |
local function="${COMP_WORDS[1]}" |
| 32 |
case $function in |
| 33 |
'get') |
| 34 |
COMPREPLY=( $(compgen -W "--source" -- "$2") ) |
| 35 |
return 0 |
| 36 |
;; |
| 37 |
'new') |
| 38 |
COMPREPLY=( $(compgen -W "--dest -- --dest-type --verbose" -- "$2") ) |
| 39 |
return 0 |
| 40 |
;; |
| 41 |
'copy') |
| 42 |
COMPREPLY=( $(compgen -W "--source --dest -- --dest-type --verbose" -- "$2") ) |
| 43 |
return 0 |
| 44 |
;; |
| 45 |
'-h'|'--help'|'-V'|'--version') |
| 46 |
return 0 |
| 47 |
;; |
| 48 |
esac |
| 49 |
return 0 |
| 50 |
} |
| 51 |
complete -F _coresched_module coresched |