]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/umount
0949688f93ef6b8b14b746fca44845333619ba0f
[thirdparty/util-linux.git] / bash-completion / umount
1 _umount_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')
9 local TYPES
10 TYPES="
11 $(\ls /lib/modules/$(uname -r)/kernel/fs | awk '{print $1, "no" $1}')
12 $(awk '{print $NF, "no" $NF}' /proc/filesystems)
13 "
14 COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
15 return 0
16 ;;
17 '-h'|'--help'|'-V'|'--version')
18 return 0
19 ;;
20 '-N'|'--namespace')
21 local NAMESPACE
22 NAMESPACE="$(lsns --type mnt --output PATH --noheadings)"
23 COMPREPLY=( $(compgen -W "$NAMESPACE" -- $cur) )
24 return 0
25 ;;
26 esac
27 case $cur in
28 -*)
29 OPTS=" --all
30 --all-targets
31 --no-canonicalize
32 --detach-loop
33 --fake
34 --force
35 --internal-only
36 --namespace
37 --no-mtab
38 --lazy
39 --test-opts
40 --recursive
41 --read-only
42 --types
43 --quiet
44 --verbose
45 --help
46 --version"
47 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
48 return 0
49 ;;
50 esac
51
52 local oldifs=$IFS
53 IFS=$'\n'
54 COMPREPLY=( $( compgen -W "$(findmnt -lno TARGET | gawk \
55 '{
56 if ($0 ~ ENVIRON["HOME"]) {
57 homeless = $0
58 homeless = gensub(ENVIRON["HOME"], "\\\\~", "g", homeless)
59 homeless = gensub(/(\s)/, "\\\\\\1", "g", homeless)
60 print homeless
61 }
62 if ($0 ~ ENVIRON["PWD"]) {
63 reldir = $0
64 reldir = gensub(ENVIRON["PWD"]"/", "", "g", reldir)
65 reldir = gensub(/(\s)/, "\\\\\\1", "g", reldir)
66 print "./" reldir
67 print reldir
68 }
69 gsub(/\s/, "\\\\&")
70 print $0
71 }'
72 )" -- "$cur" ) )
73 IFS=$oldifs
74 }
75 complete -F _umount_module umount