/bash_completion_lib/complete/wvdial

http://github.com/brinkman83/bashrc · #! · 49 lines · 40 code · 9 blank · 0 comment · 0 complexity · fec91da11cf27da14be9e3050f192e63 MD5 · raw file

  1. # wvdial(1) completion
  2. comp_include _filedir _get_cword
  3. _wvdial()
  4. {
  5. local cur prev config i IFS=$'\t\n'
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. case $prev in
  10. --config)
  11. _filedir
  12. return 0
  13. ;;
  14. esac
  15. case $cur in
  16. -*)
  17. COMPREPLY=( $( compgen -W '--config --chat \
  18. --remotename --help --version --no-syslog' \
  19. -- $cur ) )
  20. ;;
  21. *)
  22. # start with global and personal config files
  23. config="/etc/wvdial.conf"$'\t'"$HOME/.wvdialrc"
  24. # replace with command line config file if present
  25. for (( i=1; i < COMP_CWORD; i++ )); do
  26. if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
  27. config=${COMP_WORDS[i+1]}
  28. break
  29. fi
  30. done
  31. # parse config files for sections and
  32. # remove default section
  33. COMPREPLY=( $( sed -ne \
  34. "s|^\[Dialer \($cur.*\)\]$|\1|p" \
  35. $config 2>/dev/null |grep -v '^Defaults$'))
  36. # escape spaces
  37. COMPREPLY=${COMPREPLY// /\\ }
  38. ;;
  39. esac
  40. } # _wvdial()