mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
The program can be started in line editing mode. In this mode, the
current line can be edited by inserting/deleting characters. Escape
values can be used for bytes.
Controls:
printable - adds character to the position of the cursor
RIGHT, LEFT - moves cursor in the line
UP, DOWN - gets prevoiusly sent lines from the history
BACKSPACE - deletes character before the cursor
ENTER - sends line
Commands:
:? - list available commands
:q - quit
:v - show version
:: - send ':'
Escapes:
\dNNN - decimal NNN (e.g: \d045 = 45)
\xNN - hexadecimal NN (e.g: \xff = 255)
\bNNNNNNNN - binary NNNNNNNN (e.g: \b00000001 = 1)
Added option --line-edit, to start the program in line editing mode.
Added option --no-newline-in-line-edit to prevent sending newline
characters.
123 lines
3.3 KiB
Text
123 lines
3.3 KiB
Text
#
|
|
# Bash completion script for tio.
|
|
#
|
|
|
|
_tio()
|
|
{
|
|
local cur prev opts base ttys
|
|
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 \
|
|
-o --output-delay \
|
|
-n --no-autoconnect \
|
|
-e --local-echo \
|
|
-t --timestamp \
|
|
-l --log \
|
|
-m --map \
|
|
-x --hex \
|
|
--newline-in-hex \
|
|
--line-edit \
|
|
--no-newline-in-line-edit \
|
|
-v --version \
|
|
-t --timestamp \
|
|
-h --help"
|
|
|
|
# Complete the arguments to the options.
|
|
case "${prev}" in
|
|
-b | --baudrate)
|
|
local baudrates="@BAUDRATES@"
|
|
COMPREPLY=( $(compgen -W "$baudrates" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
-d | --databits)
|
|
COMPREPLY=( $(compgen -W "5 6 7 8" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
-h | --local-echo)
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${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
|
|
;;
|
|
-o | --output-delay)
|
|
COMPREPLY=( $(compgen -W "0 1 10 100" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
-n | --no-autoconnect)
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
-l | --log)
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
-m | --map)
|
|
COMPREPLY=( $(compgen -W "ICRNL IGNCR INLCR INLCRNL OCRNL ODELBS ONLCRNL" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
-t | --timestamp)
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
-x | --hex)
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
--newline-in-hex)
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
--line-edit)
|
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
--no-newline-in-line-edit)
|
|
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
|
|
case "${cur}" in
|
|
-*)
|
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
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
|
|
complete -o default -F _tio tio
|