/bash_completion.d/minicom

http://github.com/brinkman83/bashrc · #! · 54 lines · 48 code · 6 blank · 0 comment · 0 complexity · aff0b9e2243231a141bed69c11e4c848 MD5 · raw file

  1. # bash completion for minicom
  2. have minicom &&
  3. _minicom()
  4. {
  5. local cur prev confdir
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. case $prev in
  10. -@(a|c))
  11. COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) )
  12. return 0
  13. ;;
  14. -@(S|C))
  15. _filedir
  16. return 0
  17. ;;
  18. -P)
  19. COMPREPLY=( $( command ls /dev/tty* ) )
  20. COMPREPLY=( $( compgen -W '${COMPREPLY[@]} ${COMPREPLY[@]#/dev/}' \
  21. -- "$cur" ) )
  22. return 0
  23. ;;
  24. esac
  25. if [[ "$cur" == -* ]]; then
  26. COMPREPLY=( $( compgen -W '-s -o -m -M -z -l -L -w -a -t \
  27. -c -S -d -p -C -T -7 -8' -- "$cur" ) )
  28. return 0
  29. else
  30. [ -n "$( command ls /etc/minirc.* 2>/dev/null)" ] \
  31. && confdir=/etc
  32. [ -n "$( command ls /etc/minicom/minirc.* 2>/dev/null)" ] \
  33. && confdir=/etc/minicom
  34. if [ -n "$confdir" ]; then
  35. COMPREPLY=( $( compgen -W '$( command ls $confdir/minirc.* | \
  36. sed -e "s|$confdir/minirc.||")' -- "$cur" ) )
  37. return 0
  38. fi
  39. fi
  40. } &&
  41. complete -F _minicom $default minicom
  42. # Local variables:
  43. # mode: shell-script
  44. # sh-basic-offset: 4
  45. # sh-indent-comment: t
  46. # indent-tabs-mode: nil
  47. # End:
  48. # ex: ts=4 sw=4 et filetype=sh