Created
December 19, 2015 18:00
-
-
Save cabo/a0069aae2acae1dcdf5c to your computer and use it in GitHub Desktop.
Bash function for completion of serial lines for Gnu screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scu() { | |
local fn=$1 | |
shift | |
echo opening /dev/cu."$fn" "$@"... | |
screen /dev/cu."${fn// / }" "$@" ; stty sane | |
} | |
function _scu() { | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
case "$cur" in | |
[0-9]*) | |
local v="4800 9600 19200 38400 57600 115200 230400" ;; | |
*) | |
local v=$(cd /dev/; find -x cu.* -type c -depth 0 | sed s/...// | sed 's/ / /g') | |
esac | |
COMPREPLY=( $(compgen -W "$v" -- $cur) ) | |
} | |
complete -F _scu scu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment