Debian Codegraph @

bash-completion/findmnt

raw
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')
21 local IFS=$'\n'
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
41 done < <($1 -rno OPTIONS)
42 COMPREPLY=( $(compgen -W "${!MNT_OPTS[@]}" -- $cur) )
43 return 0
44 ;;
45 '-o'|'--output')
46 local prefix realcur OUTPUT_ALL OUTPUT
47 realcur="${cur##*,}"
48 prefix="${cur%$realcur}"
49
50 OUTPUT_ALL="SOURCE TARGET FSTYPE OPTIONS VFS-OPTIONS
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"
55
56 for WORD in $OUTPUT_ALL; do
57 if ! [[ $prefix == *"$WORD"* ]]; then
58 OUTPUT="$WORD ${OUTPUT:-""}"
59 fi
60 done
61 compopt -o nospace
62 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
63 return 0
64 ;;
65 '-t'|'--types')
66 local TYPES
67 TYPES="adfs affs autofs cifs coda coherent cramfs
68 debugfs devpts efs ext2 ext3 ext4 hfs
69 hfsplus hpfs iso9660 jfs minix msdos
70 ncpfs nfs nfs4 ntfs3 proc qnx4 ramfs
71 reiserfs romfs squashfs smbfs sysv tmpfs
72 ubifs udf ufs umsdos usbfs vfat xenix xfs"
73 COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
74 return 0
75 ;;
76 '-S'|'--source')
77 local DEV_MPOINT
78 DEV_MPOINT=$($1 -rno SOURCE | command grep ^/dev)
79 COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
80 return 0
81 ;;
82 '-T'|'--target')
83 local DEV_MPOINT
84 DEV_MPOINT=$($1 -rno TARGET)
85 COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
86 return 0
87 ;;
88 '-M'|'--mountpoint')
89 local IFS=$'\n'
90 compopt -o filenames
91 COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
92 return 0
93 ;;
94 '-h'|'--help'|'-V'|'--version')
95 return 0
96 ;;
97 esac
98 case $cur in
99 -*)
100 OPTS="--fstab
101 --mtab
102 --kernel
103 --poll
104 --timeout
105 --all
106 --ascii
107 --canonicalize
108 --df
109 --dfi
110 --direction
111 --evaluate
112 --tab-file
113 --first-only
114 --hyperlink
115 --id
116 --uniq-id
117 --invert
118 --json
119 --list
120 --task
121 --noheadings
122 --notruncate
123 --options
124 --output
125 --output-all
126 --pairs
127 --raw
128 --types
129 --nofsroot
130 --submounts
131 --source
132 --target
133 --mountpoint
134 --help
135 --tree
136 --real
137 --pseudo
138 --list-columns
139 --bytes
140 --filter
141 --nocanonicalize
142 --shadowed
143 --shell
144 --uniq
145 --verbose
146 --verify
147 --vfs-all
148 --version"
149 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
150 return 0
151 ;;
152 esac
153 local DEV_MPOINT
154 DEV_MPOINT=$($1 -rno TARGET,SOURCE)
155 COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
156 return 0
157 }
158 complete -F _findmnt_module findmnt