]> git.sur5r.net Git - tio/blob - src/bash-completion/tio.in
New upstream version 1.34
[tio] / src / bash-completion / tio.in
1 #
2 # Bash completion script for tio.
3 #
4
5 _tio()
6 {
7     local cur prev opts base ttys
8     COMPREPLY=()
9     cur="${COMP_WORDS[COMP_CWORD]}"
10     prev="${COMP_WORDS[COMP_CWORD-1]}"
11
12     #  The options we'll complete.
13     opts="-b --baudrate \
14           -d --databits \
15           -f --flow \
16           -s --stopbits \
17           -p --parity \
18           -o --output-delay \
19           -n --no-autoconnect \
20           -l --log \
21           -m --map \
22           -v --version \
23           -t --timestamp \
24           -L --list-devices \
25           -c --color \
26           -h --help"
27
28     #  Complete the arguments to the options.
29     case "${prev}" in
30         -b | --baudrate)
31             local baudrates="@baudrates@"
32             COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
33             return 0
34             ;;
35         -d | --databits)
36             COMPREPLY=( $(compgen -W "5 6 7 8" -- ${cur}) )
37             return 0
38             ;;
39         -h | --local-echo)
40             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
41             return 0
42             ;;
43         -f | --flow)
44             COMPREPLY=( $(compgen -W "hard soft none" -- ${cur}) )
45             return 0
46             ;;
47         -s | --stopbits)
48             COMPREPLY=( $(compgen -W "1 2" -- ${cur}) )
49             return 0
50             ;;
51         -p | --parity)
52             COMPREPLY=( $(compgen -W "even odd none" -- ${cur}) )
53             return 0
54             ;;
55         -o | --output-delay)
56             COMPREPLY=( $(compgen -W "0 1 10 100" -- ${cur}) )
57             return 0
58             ;;
59         -n | --no-autoconnect)
60             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
61             return 0
62             ;;
63         -l | --log)
64             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
65             return 0
66             ;;
67         -m | --map)
68             COMPREPLY=( $(compgen -W "ICRNL IGNCR INLCR INLCRNL OCRNL ODELBS ONLCRNL" -- ${cur}) )
69             return 0
70             ;;
71         -t | --timestamp)
72             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
73             return 0
74             ;;
75         -L | --list-devices)
76             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
77             return 0
78             ;;
79         -c | --color)
80             COMPREPLY=( $(compgen -W "$(seq 0 255)" -- ${cur}) )
81             return 0
82             ;;
83         -v | --version)
84             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
85             return 0
86             ;;
87         -h | --help)
88             COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
89             return 0
90             ;;
91         *)
92         ;;
93     esac
94     case "${cur}" in
95         -*)
96             COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
97             return 0
98             ;;
99     esac
100
101     if [ -d /dev/serial/by-id ]; then
102         ttys=$(printf '%s\n' /dev/tty* /dev/serial/by-id/*)
103     else
104         ttys=$(printf '%s\n' /dev/tty*)
105     fi
106     COMPREPLY=( $(compgen -W "${ttys}" -- ${cur}) )
107     return 0
108 }
109
110 # Bind completion to tio command
111 complete -o default -F _tio tio