mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Completed autocompletion
Autocompletion now resolves all arguments. Also renamed 'gotty-bash-completion.sh' to 'gotty' to comply with the normal naming scheme for completion files in /etc/bash_completion.d .
This commit is contained in:
parent
cfa4430370
commit
df8652f05d
2 changed files with 25 additions and 24 deletions
94
src/bash-completion/gotty
Normal file
94
src/bash-completion/gotty
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#
|
||||
# Bash autocompletion script for gotty.
|
||||
#
|
||||
|
||||
_gotty()
|
||||
{
|
||||
local cur prev opts base
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
# The options we'll complete.
|
||||
opts="-b --baudrate \
|
||||
-d --databits \
|
||||
-f --flow \
|
||||
-s --stopbits \
|
||||
-p --parity \
|
||||
-n --no-autoconnect \
|
||||
-v --version \
|
||||
-h --help"
|
||||
|
||||
# Complete the arguments to the options.
|
||||
case "${prev}" in
|
||||
-b | --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
|
||||
;;
|
||||
-d | --databits)
|
||||
COMPREPLY=( $(compgen -W "5 6 7 8" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-f | --flow)
|
||||
COMPREPLY=( $(compgen -W "hard soft none" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-s | --stopbits)
|
||||
COMPREPLY=( $(compgen -W "1 2" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-p | --parity)
|
||||
COMPREPLY=( $(compgen -W "even odd none" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-n | --no-autoconnect)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-v | --version)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
-h | --help)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
}
|
||||
|
||||
# Bind completion to gotty command
|
||||
complete -o default -F _gotty gotty
|
||||
Loading…
Add table
Add a link
Reference in a new issue