]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/umount
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / umount
CommitLineData
2211b13e
SK
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="
d092911b
SK
11 $(\ls /lib/modules/$(uname -r)/kernel/fs | awk '{print $1, "no" $1}')
12 $(awk '{print $NF, "no" $NF}' /proc/filesystems)
13 "
2211b13e
SK
14 COMPREPLY=( $(compgen -W "$TYPES" -- $cur) )
15 return 0
16 ;;
17 '-h'|'--help'|'-V'|'--version')
18 return 0
19 ;;
d482a0bd
KZ
20 '-N'|'--namespace')
21 local NAMESPACE
22 NAMESPACE="$(lsns --type mnt --output PATH --noheadings)"
23 COMPREPLY=( $(compgen -W "$NAMESPACE" -- $cur) )
24 return 0
25 ;;
2211b13e
SK
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
d482a0bd 36 --namespace
2211b13e
SK
37 --no-mtab
38 --lazy
39 --test-opts
40 --recursive
41 --read-only
42 --types
5feae697 43 --quiet
2211b13e
SK
44 --verbose
45 --help
46 --version"
47 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
48 return 0
49 ;;
50 esac
75f03bad
KZ
51
52 local oldifs=$IFS
53 IFS=$'\n'
3ebfc8d3
SK
54 COMPREPLY=( $( compgen -W "$(findmnt -lno TARGET | awk \
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" ) )
75f03bad 73 IFS=$oldifs
2211b13e
SK
74}
75complete -F _umount_module umount