]>
Commit | Line | Data |
---|---|---|
76dceb10 SK |
1 | _findmnt_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 | '-p'|'--poll') | |
9 | COMPREPLY=( $(compgen -W "=list" -- $cur) ) | |
10 | return 0 | |
11 | ;; | |
12 | '-w'|'--timeout') | |
13 | COMPREPLY=( $(compgen -W "timeout" -- $cur) ) | |
14 | return 0 | |
15 | ;; | |
16 | '-d'|'--direction') | |
17 | COMPREPLY=( $(compgen -W "forward backward" -- $cur) ) | |
18 | return 0 | |
19 | ;; | |
20 | '-F'|'--tab-file') | |
ce3e6b15 | 21 | local IFS=$'\n' |
76dceb10 SK |
22 | compopt -o filenames |
23 | COMPREPLY=( $(compgen -f -- $cur) ) | |
24 | return 0 | |
25 | ;; | |
26 | '-N'|'--task') | |
27 | local TID='' I ARR | |
28 | for I in /proc/*/mountinfo; do IFS=/ read -ra ARR <<< "$I"; TID+="${ARR[2]} "; done | |
29 | COMPREPLY=( $(compgen -W "$TID" -- $cur) ) | |
30 | return 0 | |
31 | ;; | |
32 | '-O'|'--options') | |
33 | local MTAB_3RD I | |
34 | declare -a TMP_ARR | |
35 | declare -A MNT_OPTS | |
36 | while read MTAB_3RD; do | |
37 | IFS=',' read -ra TMP_ARR <<<"$MTAB_3RD" | |
38 | for I in ${TMP_ARR[@]}; do | |
39 | MNT_OPTS[$I]='1' | |
40 | done | |
396a6d7d | 41 | done < <($1 -rno OPTIONS) |
d6b975ef | 42 | COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) ) |
76dceb10 SK |
43 | return 0 |
44 | ;; | |
45 | '-o'|'--output') | |
b5b80e5a BE |
46 | local prefix realcur OUTPUT_ALL OUTPUT |
47 | realcur="${cur##*,}" | |
48 | prefix="${cur%$realcur}" | |
49 | ||
50 | OUTPUT_ALL="SOURCE TARGET FSTYPE OPTIONS VFS-OPTIONS | |
76dceb10 SK |
51 | FS-OPTIONS LABEL UUID PARTLABEL PARTUUID |
52 | MAJ\:MIN ACTION OLD-TARGET OLD-OPTIONS | |
53 | SIZE AVAIL USED USE% FSROOT TID ID | |
54 | OPT-FIELDS PROPAGATION FREQ PASSNO" | |
b5b80e5a BE |
55 | |
56 | for WORD in $OUTPUT_ALL; do | |
57 | if ! [[ $prefix == *"$WORD"* ]]; then | |
abbcec4f | 58 | OUTPUT="$WORD ${OUTPUT:-""}" |
b5b80e5a BE |
59 | fi |
60 | done | |
76dceb10 | 61 | compopt -o nospace |
b5b80e5a | 62 | COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) ) |
76dceb10 SK |
63 | return 0 |
64 | ;; | |
65 | '-t'|'--types') | |
66 | local TYPES | |
67 | TYPES="adfs affs autofs cifs coda coherent cramfs | |
6070a985 | 68 | debugfs devpts efs ext2 ext3 ext4 hfs |
76dceb10 SK |
69 | hfsplus hpfs iso9660 jfs minix msdos |
70 | ncpfs nfs nfs4 ntfs proc qnx4 ramfs | |
71 | reiserfs romfs squashfs smbfs sysv tmpfs | |
556c9c48 | 72 | ubifs udf ufs umsdos usbfs vfat xenix xfs" |
76dceb10 SK |
73 | COMPREPLY=( $(compgen -W "$TYPES" -- $cur) ) |
74 | return 0 | |
75 | ;; | |
76 | '-S'|'--source') | |
77 | local DEV_MPOINT | |
396a6d7d | 78 | DEV_MPOINT=$($1 -rno SOURCE | grep ^/dev) |
76dceb10 SK |
79 | COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) |
80 | return 0 | |
81 | ;; | |
82 | '-T'|'--target') | |
83 | local DEV_MPOINT | |
396a6d7d | 84 | DEV_MPOINT=$($1 -rno TARGET) |
76dceb10 SK |
85 | COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) |
86 | return 0 | |
87 | ;; | |
24bdce6e SK |
88 | '-M'|'--mountpoint') |
89 | local IFS=$'\n' | |
90 | compopt -o filenames | |
100a4393 | 91 | COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) ) |
24bdce6e SK |
92 | return 0 |
93 | ;; | |
d4f9b8d7 VS |
94 | '-h'|'--help'|'-V'|'--version') |
95 | return 0 | |
96 | ;; | |
76dceb10 SK |
97 | esac |
98 | case $cur in | |
99 | -*) | |
0d5b9b8a VS |
100 | OPTS="--fstab |
101 | --mtab | |
102 | --kernel | |
103 | --poll | |
104 | --timeout | |
105 | --all | |
106 | --ascii | |
107 | --canonicalize | |
108 | --df | |
109 | --direction | |
110 | --evaluate | |
111 | --tab-file | |
112 | --first-only | |
113 | --invert | |
24bdce6e | 114 | --json |
0d5b9b8a VS |
115 | --list |
116 | --task | |
117 | --noheadings | |
118 | --notruncate | |
119 | --options | |
120 | --output | |
00147883 | 121 | --output-all |
0d5b9b8a VS |
122 | --pairs |
123 | --raw | |
124 | --types | |
125 | --nofsroot | |
126 | --submounts | |
127 | --source | |
128 | --target | |
24bdce6e | 129 | --mountpoint |
0d5b9b8a | 130 | --help |
3ebe5477 | 131 | --tree |
4c9afd6e KZ |
132 | --real |
133 | --pseudo | |
0d5b9b8a | 134 | --version" |
76dceb10 SK |
135 | COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
136 | return 0 | |
137 | ;; | |
138 | esac | |
139 | local DEV_MPOINT | |
396a6d7d | 140 | DEV_MPOINT=$($1 -rno TARGET,SOURCE) |
76dceb10 SK |
141 | COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) ) |
142 | return 0 | |
143 | } | |
144 | complete -F _findmnt_module findmnt |