]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/losetup
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / losetup
1 _losetup_module()
2 {
3 local cur prev OPTS ARG
4 COMPREPLY=()
5 cur="${COMP_WORDS[COMP_CWORD]}"
6 prev="${COMP_WORDS[COMP_CWORD-1]}"
7 case $prev in
8 '-d'|'--detach')
9 ARG="$($1 --output NAME | awk '{if (1 < NR) {print}}')"
10 COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
11 return 0
12 ;;
13 '-j'|'--associated')
14 ARG="$($1 --output BACK-FILE | awk '{if (1 < NR) {print}}')"
15 COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
16 return 0
17 ;;
18 '-c'|'--set-capacity')
19 ARG="$(for I in /dev/loop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)"
20 COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
21 return 0
22 ;;
23 '-o'|'--offset'|'--sizelimit')
24 COMPREPLY=( $(compgen -W "number" -- $cur) )
25 return 0
26 ;;
27 '-O'|'--output')
28 local prefix realcur OUTPUT_ALL OUTPUT
29 realcur="${cur##*,}"
30 prefix="${cur%$realcur}"
31 OUTPUT_ALL="NAME AUTOCLEAR BACK-FILE BACK-INO
32 BACK-MAJ:MIN MAJ:MIN OFFSET PARTSCAN RO
33 SIZELIMIT DIO"
34 for WORD in $OUTPUT_ALL; do
35 if ! [[ $prefix == *"$WORD"* ]]; then
36 OUTPUT="$WORD ${OUTPUT:-""}"
37 fi
38 done
39 compopt -o nospace
40 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
41 return 0
42 ;;
43 '-h'|'--help'|'-V'|'--version')
44 return 0
45 ;;
46 esac
47 case $cur in
48 -*)
49 OPTS="--all
50 --detach
51 --detach-all
52 --find
53 --set-capacity
54 --associated
55 --nooverlap
56 --offset
57 --sizelimit
58 --partscan
59 --read-only
60 --show
61 --verbose
62 --json
63 --list
64 --noheadings
65 --output
66 --output-all
67 --raw
68 --help
69 --version"
70 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
71 return 0
72 ;;
73 esac
74 local IFS=$'\n'
75 compopt -o filenames
76 COMPREPLY=( $(compgen -f -- $cur) )
77 return 0
78 }
79 complete -F _losetup_module losetup