figlet.bashcomp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright 1999-2005 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # bash command-line completion for figlet
  4. # author: Aaron Walker <ka0ttic@gentoo.org>
  5. _figlet() {
  6. local cur prev opts x
  7. COMPREPLY=()
  8. cur="${COMP_WORDS[COMP_CWORD]}"
  9. prev="${COMP_WORDS[COMP_CWORD-1]}"
  10. opts="-f -d -c -l -r -x -t -w -p -n -D -E -C -N -s -S -k -W -o \
  11. -m -v -I -L -R -X"
  12. if [[ "${cur}" == -* || ${COMP_CWORD} -eq 1 ]] ; then
  13. COMPREPLY=( $(compgen -W "${opts}" -- $cur) )
  14. return 0
  15. fi
  16. case "${prev}" in
  17. -f)
  18. COMPREPLY=( $(compgen -f -- $cur) \
  19. $(compgen -W "$(\
  20. for x in /usr/share/figlet/*.flf ; do \
  21. [[ -f ${x} ]] && { local y=${x##*/} ; echo ${y%.*} ; } \
  22. done)" -- $cur) )
  23. ;;
  24. -d)
  25. COMPREPLY=( $(compgen -d -S '/' -- $cur) )
  26. ;;
  27. -C)
  28. COMPREPLY=( $(compgen -f -- $cur) \
  29. $(compgen -W "$(\
  30. for x in /usr/share/figlet/*.flc ; do \
  31. [[ -f ${x} ]] && { local y=${x##*/} ; echo ${y%.*} ; } \
  32. done)" -- $cur) )
  33. ;;
  34. -m)
  35. COMPREPLY=( $(compgen -W "$(\
  36. for ((x = 1 ; x < 64 ; x++)) ; do \
  37. echo ${x} ; \
  38. done)" ) )
  39. ;;
  40. -I)
  41. COMPREPLY=( $(compgen -W "-1 0 1 2 3 4" -- $cur) )
  42. ;;
  43. esac
  44. }
  45. complete -o filenames -F _figlet figlet
  46. # vim: set ft=sh tw=80 sw=4 et :