]>
Commit | Line | Data |
---|---|---|
d092911b SK |
1 | _lsmem_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 OUTPUT_ALL OUTPUT | |
10 | realcur="${cur##*,}" | |
11 | prefix="${cur%$realcur}" | |
12 | OUTPUT_ALL='RANGE SIZE STATE REMOVABLE BLOCK NODE' | |
13 | for WORD in $OUTPUT_ALL; do | |
14 | if ! [[ $prefix == *"$WORD"* ]]; then | |
15 | OUTPUT="$WORD $OUTPUT" | |
16 | fi | |
17 | done | |
18 | compopt -o nospace | |
19 | COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- "$realcur") ) | |
20 | return 0 | |
21 | ;; | |
22 | '-s'|'--sysroot') | |
23 | local IFS=$'\n' | |
24 | compopt -o filenames | |
25 | COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) ) | |
26 | return 0 | |
27 | ;; | |
28 | '--summary') | |
29 | COMPREPLY=( $(compgen -W "never always only" -- $cur) ) | |
30 | return 0 | |
31 | ;; | |
32 | '-h'|'--help'|'-V'|'--version') | |
33 | return 0 | |
34 | ;; | |
35 | esac | |
36 | OPTS=" | |
37 | --json | |
38 | --pairs | |
39 | --all | |
40 | --bytes | |
41 | --noheadings | |
42 | --output | |
43 | --raw | |
44 | --sysroot | |
45 | --summary | |
46 | --help | |
47 | --version | |
48 | " | |
49 | COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) | |
50 | return 0 | |
51 | } | |
52 | complete -F _lsmem_module lsmem |