_tio()
{
- local cur prev opts base
+ local cur prev opts base ttys
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
-l --log \
-m --map \
-v --version \
+ -t --timestamp \
+ -L --list-devices \
+ -c --color \
-h --help"
# Complete the arguments to the options.
case "${prev}" in
-b | --baudrate)
- local baudrates="@BAUDRATES@"
+ local baudrates="@baudrates@"
COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
return 0
;;
COMPREPLY=( $(compgen -W "ICRNL IGNCR INLCR INLCRNL OCRNL ODELBS ONLCRNL" -- ${cur}) )
return 0
;;
+ -t | --timestamp)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ -L | --list-devices)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ -c | --color)
+ COMPREPLY=( $(compgen -W "$(seq 0 255)" -- ${cur}) )
+ return 0
+ ;;
-v | --version)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
*)
;;
esac
+ case "${cur}" in
+ -*)
+ COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
+ return 0
+ ;;
+ esac
- COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
- return 0
+ if [ -d /dev/serial/by-id ]; then
+ ttys=$(printf '%s\n' /dev/tty* /dev/serial/by-id/*)
+ else
+ ttys=$(printf '%s\n' /dev/tty*)
+ fi
+ COMPREPLY=( $(compgen -W "${ttys}" -- ${cur}) )
+ return 0
}
# Bind completion to tio command