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
|
|
@ -1,4 +1,4 @@
|
|||
bin_PROGRAMS = gotty
|
||||
gotty_SOURCES = tty.c options.c device.c main.c
|
||||
bashcompletiondir=$(sysconfdir)/bash_completion.d
|
||||
dist_bashcompletion_DATA=gotty-bash-completion.sh
|
||||
dist_bashcompletion_DATA=bash-completion/gotty
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
#
|
||||
# Bash autocompletion script for gotty.
|
||||
#
|
||||
|
||||
_gotty()
|
||||
{
|
||||
local cur prev opts base
|
||||
|
|
@ -5,24 +9,19 @@ _gotty()
|
|||
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"
|
||||
opts="-b --baudrate \
|
||||
-d --databits \
|
||||
-f --flow \
|
||||
-s --stopbits \
|
||||
-p --parity \
|
||||
-n --no-autoconnect \
|
||||
-v --version \
|
||||
-h --help"
|
||||
|
||||
|
||||
#
|
||||
# Complete the arguments to some of the options.
|
||||
#
|
||||
# Complete the arguments to the options.
|
||||
case "${prev}" in
|
||||
--baudrate)
|
||||
-b | --baudrate)
|
||||
local baudrates="0 \
|
||||
50 \
|
||||
75 \
|
||||
|
|
@ -55,31 +54,31 @@ _gotty()
|
|||
COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--databits)
|
||||
-d | --databits)
|
||||
COMPREPLY=( $(compgen -W "5 6 7 8" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--flow)
|
||||
-f | --flow)
|
||||
COMPREPLY=( $(compgen -W "hard soft none" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--stopbits)
|
||||
-s | --stopbits)
|
||||
COMPREPLY=( $(compgen -W "1 2" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--parity)
|
||||
-p | --parity)
|
||||
COMPREPLY=( $(compgen -W "even odd none" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--no-autoconnect)
|
||||
-n | --no-autoconnect)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--version)
|
||||
-v | --version)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
--help)
|
||||
-h | --help)
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
|
@ -87,7 +86,9 @@ _gotty()
|
|||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
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