Skip to content

Instantly share code, notes, and snippets.

@cabo
Created December 19, 2015 18:00
Show Gist options
  • Save cabo/a0069aae2acae1dcdf5c to your computer and use it in GitHub Desktop.
Save cabo/a0069aae2acae1dcdf5c to your computer and use it in GitHub Desktop.
Bash function for completion of serial lines for Gnu screen
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