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
|
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
|
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()
|
_gotty()
|
||||||
{
|
{
|
||||||
local cur prev opts base
|
local cur prev opts base
|
||||||
|
|
@ -5,24 +9,19 @@ _gotty()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
#
|
|
||||||
# The options we'll complete.
|
# The options we'll complete.
|
||||||
#
|
opts="-b --baudrate \
|
||||||
opts="--baudrate \
|
-d --databits \
|
||||||
--databits \
|
-f --flow \
|
||||||
--flow \
|
-s --stopbits \
|
||||||
--stopbits \
|
-p --parity \
|
||||||
--parity \
|
-n --no-autoconnect \
|
||||||
--no-autoconnect \
|
-v --version \
|
||||||
--version \
|
-h --help"
|
||||||
--help"
|
|
||||||
|
|
||||||
|
# Complete the arguments to the options.
|
||||||
#
|
|
||||||
# Complete the arguments to some of the options.
|
|
||||||
#
|
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
--baudrate)
|
-b | --baudrate)
|
||||||
local baudrates="0 \
|
local baudrates="0 \
|
||||||
50 \
|
50 \
|
||||||
75 \
|
75 \
|
||||||
|
|
@ -55,31 +54,31 @@ _gotty()
|
||||||
COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--databits)
|
-d | --databits)
|
||||||
COMPREPLY=( $(compgen -W "5 6 7 8" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "5 6 7 8" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--flow)
|
-f | --flow)
|
||||||
COMPREPLY=( $(compgen -W "hard soft none" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "hard soft none" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--stopbits)
|
-s | --stopbits)
|
||||||
COMPREPLY=( $(compgen -W "1 2" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "1 2" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--parity)
|
-p | --parity)
|
||||||
COMPREPLY=( $(compgen -W "even odd none" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "even odd none" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--no-autoconnect)
|
-n | --no-autoconnect)
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--version)
|
-v | --version)
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--help)
|
-h | --help)
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
|
@ -87,7 +86,9 @@ _gotty()
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Bind completion to gotty command
|
||||||
complete -o default -F _gotty gotty
|
complete -o default -F _gotty gotty
|
||||||
Loading…
Add table
Add a link
Reference in a new issue