mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Merge pull request #112 from henrikbrixandersen/bash_completion_ttys
Add bash completion of tty devices
This commit is contained in:
commit
17fafd9918
1 changed files with 14 additions and 3 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
_tio()
|
_tio()
|
||||||
{
|
{
|
||||||
local cur prev opts base
|
local cur prev opts base ttys
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
@ -81,9 +81,20 @@ _tio()
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
case "${cur}" in
|
||||||
|
-*)
|
||||||
|
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
if [ -d /dev/serial/by-id ]; then
|
||||||
return 0
|
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
|
# Bind completion to tio command
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue