]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/eject
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / eject
CommitLineData
c6f8c3f5
SK
1_eject_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 '-a'|'--auto'|'-i'|'--manualeject')
9 COMPREPLY=( $(compgen -W "off on" -- $cur) )
10 return 0
11 ;;
12 '-c'|'--changerslot')
13 # FIXME: there must be way to determine slots
14 COMPREPLY=( $(compgen -W "slot" -- $cur) )
15 return 0
16 ;;
17 '-x'|'--cdspeed')
fda59a8d 18 COMPREPLY=( $(compgen -W "$(eject --listspeed 2>/dev/null)" -- $cur) )
c6f8c3f5
SK
19 return 0
20 ;;
d4f9b8d7
VS
21 '-h'|'--help'|'-V'|'--version')
22 return 0
23 ;;
c6f8c3f5
SK
24 esac
25 case $cur in
26 -*)
0d5b9b8a
VS
27 OPTS="--auto
28 --changerslot
29 --default
30 --floppy
31 --force
32 --manualeject
33 --no-unmount
34 --no-partitions-unmount
35 --noop
36 --proc
37 --tape
38 --cdrom
39 --scsi
40 --trayclose
41 --traytoggle
42 --verbose
43 --cdspeed
44 --listspeed
45 --help
46 --version"
c6f8c3f5
SK
47 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
48 return 0
49 ;;
50 esac
51 local DEVS
52 DEVS="$(for I in /sys/class/block/*/removable; do
53 if [ $(cat $I) -ne 0 ]; then
54 OLD_IFS=$IFS
55 IFS='/';
56 ARR=($I)
57 echo "/dev/${ARR[4]}"
58 IFS=$OLD_IFS
59 fi
60 done)"
0c8865f8 61 compopt -o bashdefault -o default
c6f8c3f5
SK
62 COMPREPLY=( $(compgen -W "$DEVS" $cur) )
63 return 0
64}
65complete -F _eject_module eject