mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Added bash completion for long options
This commit is contained in:
parent
2a7c81e63c
commit
b0230109b2
2 changed files with 95 additions and 0 deletions
|
|
@ -1,2 +1,4 @@
|
||||||
bin_PROGRAMS = gotty
|
bin_PROGRAMS = gotty
|
||||||
gotty_SOURCES = tty.c options.c device.c main.c
|
gotty_SOURCES = tty.c options.c device.c main.c
|
||||||
|
bashcompletiondir=$(sysconfdir)/bash_completion.d
|
||||||
|
dist_bashcompletion_DATA=gotty-bash-completion.sh
|
||||||
|
|
|
||||||
93
src/gotty-bash-completion.sh
Normal file
93
src/gotty-bash-completion.sh
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
_gotty()
|
||||||
|
{
|
||||||
|
local cur prev opts base
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
#
|
||||||
|
# The options we'll complete.
|
||||||
|
#
|
||||||
|
opts="--baudrate \
|
||||||
|
--databits \
|
||||||
|
--flow \
|
||||||
|
--stopbits \
|
||||||
|
--parity \
|
||||||
|
--no-autoconnect \
|
||||||
|
--version \
|
||||||
|
--help"
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Complete the arguments to some of the options.
|
||||||
|
#
|
||||||
|
case "${prev}" in
|
||||||
|
--baudrate)
|
||||||
|
local baudrates="0 \
|
||||||
|
50 \
|
||||||
|
75 \
|
||||||
|
110 \
|
||||||
|
134 \
|
||||||
|
150 \
|
||||||
|
300 \
|
||||||
|
600 \
|
||||||
|
1200 \
|
||||||
|
2400 \
|
||||||
|
4800 \
|
||||||
|
9600 \
|
||||||
|
19200 \
|
||||||
|
38400 \
|
||||||
|
57600 \
|
||||||
|
115200 \
|
||||||
|
230400 \
|
||||||
|
460800 \
|
||||||
|
500000 \
|
||||||
|
576000 \
|
||||||
|
921600 \
|
||||||
|
1000000 \
|
||||||
|
1152000 \
|
||||||
|
1500000 \
|
||||||
|
2000000 \
|
||||||
|
2500000 \
|
||||||
|
3000000 \
|
||||||
|
3500000 \
|
||||||
|
4000000"
|
||||||
|
COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--databits)
|
||||||
|
COMPREPLY=( $(compgen -W "5 6 7 8" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--flow)
|
||||||
|
COMPREPLY=( $(compgen -W "hard soft none" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--stopbits)
|
||||||
|
COMPREPLY=( $(compgen -W "1 2" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--parity)
|
||||||
|
COMPREPLY=( $(compgen -W "even odd none" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--no-autoconnect)
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--version)
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
--help)
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
complete -F _gotty gotty
|
||||||
Loading…
Add table
Add a link
Reference in a new issue