]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/findmnt
Merge branch 'PR/more-poll' of github.com:karelzak/util-linux-work
[thirdparty/util-linux.git] / bash-completion / findmnt
CommitLineData
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
3dd79293 109 --dfi
0d5b9b8a
VS
110 --direction
111 --evaluate
112 --tab-file
113 --first-only
114 --invert
24bdce6e 115 --json
0d5b9b8a
VS
116 --list
117 --task
118 --noheadings
119 --notruncate
120 --options
121 --output
00147883 122 --output-all
0d5b9b8a
VS
123 --pairs
124 --raw
125 --types
126 --nofsroot
127 --submounts
128 --source
129 --target
24bdce6e 130 --mountpoint
0d5b9b8a 131 --help
3ebe5477 132 --tree
4c9afd6e
KZ
133 --real
134 --pseudo
eb4e426c 135 --list-columns
0d5b9b8a 136 --version"
76dceb10
SK
137 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
138 return 0
139 ;;
140 esac
141 local DEV_MPOINT
396a6d7d 142 DEV_MPOINT=$($1 -rno TARGET,SOURCE)
76dceb10
SK
143 COMPREPLY=( $(compgen -W "$DEV_MPOINT" -- $cur) )
144 return 0
145}
146complete -F _findmnt_module findmnt