]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/mount
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / mount
CommitLineData
2211b13e
SK
1_mount_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 '-t'|'--types')
d092911b 9 local prefix realcur TYPES
2211b13e 10 TYPES="
d092911b
SK
11 $(\ls /lib/modules/$(uname -r)/kernel/fs | awk '{print $1, "no" $1}')
12 $(awk '{print $NF, "no" $NF}' /proc/filesystems)
13 "
14 realcur="${cur##*,}"
15 prefix="${cur%$realcur}"
16 for WORD in $TYPES; do
17 if ! [[ $prefix == *"$WORD"* ]]; then
c6f0bdfe 18 TYPE_COLS="$WORD ${TYPE_COLS:-""}"
d092911b
SK
19 fi
20 done
21 compopt -o nospace
22 COMPREPLY=( $(compgen -P "$prefix" -W "$TYPE_COLS" -S ',' -- $realcur) )
2211b13e
SK
23 return 0
24 ;;
25 '-L'|'--label')
26 local LABELS
27 LABELS="$(lsblk -o LABEL -nr)"
28 COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
29 return 0
30 ;;
31 '-U'|'--uuid')
32 local UUIDS
33 UUIDS="$(lsblk -o UUID -nr)"
34 COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
35 return 0
36 ;;
5feae697
SK
37 '-N'|'--namespace')
38 local NAMESPACE
d482a0bd 39 NAMESPACE="$(lsns --type mnt --output PATH --noheadings)"
5feae697
SK
40 COMPREPLY=( $(compgen -W "$NAMESPACE" -- $cur) )
41 return 0
42 ;;
43 '--options-mode')
44 COMPREPLY=( $(compgen -W "ignore append prepend replace" -- $cur) )
45 return 0
46 ;;
47 '--options-source')
48 COMPREPLY=( $(compgen -W "fstab mtab disable" -- $cur) )
49 return 0
50 ;;
2211b13e
SK
51 '-h'|'--help'|'-V'|'--version')
52 return 0
53 ;;
54 esac
55 case $cur in
56 -*)
57 OPTS=" --all
58 --no-canonicalize
59 --fake
60 --fork
61 --fstab
62 --help
63 --internal-only
64 --show-labels
65 --no-mtab
66 --options
5feae697
SK
67 --options-mode
68 --options-source
69 --options-source-force
2211b13e
SK
70 --test-opts
71 --read-only
72 --types
73 --source
74 --target
75 --verbose
76 --version
77 --read-write
5feae697 78 --namespace
2211b13e
SK
79 --label
80 --uuid
81 --bind
82 --move
83 --rbind
84 --make-shared
85 --make-slave
86 --make-private
87 --make-unbindable
88 --make-rshared
89 --make-rslave
90 --make-rprivate
91 --make-runbindable"
92 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
93 return 0
94 ;;
95 esac
ce3e6b15 96 local IFS=$'\n'
2211b13e
SK
97 compopt -o filenames
98 COMPREPLY=( $(compgen -f -- $cur) )
99 return 0
100}
101complete -F _mount_module mount