/bash_completion.d/pon

http://github.com/brinkman83/bashrc · #! · 51 lines · 39 code · 12 blank · 0 comment · 0 complexity · 41cf8cde5bd9fefe51100a051947b118 MD5 · raw file

  1. # Debian GNU/Linux pon/poff(1) completion
  2. # Copyright 2002 Baruch Even <baruch@debian.org>
  3. # License: GNU GPL v2 or later
  4. have pon &&
  5. _pon()
  6. {
  7. local cur conns
  8. [ -r /etc/ppp/peers/ ] || return 0
  9. COMPREPLY=()
  10. cur=${COMP_WORDS[COMP_CWORD]}
  11. conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$')
  12. if [ $COMP_CWORD -eq 1 ]; then
  13. COMPREPLY=( $(compgen -o filenames -W "$conns" $cur) )
  14. fi
  15. return 0
  16. }
  17. [ "$have" ] && complete -F _pon pon
  18. have poff &&
  19. _poff()
  20. {
  21. local prev cur conns
  22. [ -r /etc/ppp/peers/ ] || return 0
  23. COMPREPLY=()
  24. prev=${COMP_WORDS[COMP_CWORD-1]}
  25. cur=${COMP_WORDS[COMP_CWORD]}
  26. conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$')
  27. if [[ "$cur" == -* ]]; then
  28. COMPREPLY=( $(compgen -W '-r -d -c -a -h -v' -- $cur) )
  29. return 0
  30. fi
  31. # first parameter on line or first since an option?
  32. if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || \
  33. [[ "$prev" == -* ]]; then
  34. COMPREPLY=( $(compgen -o filenames -W "$conns" $cur) )
  35. fi
  36. return 0
  37. }
  38. [ "$have" ] && complete -F _poff poff
  39. # vim:ft=sh: