pygments.bashcomp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!bash
  2. #
  3. # Bash completion support for Pygments (the 'pygmentize' command).
  4. #
  5. _pygmentize()
  6. {
  7. local cur prev
  8. COMPREPLY=()
  9. cur=`_get_cword`
  10. prev=${COMP_WORDS[COMP_CWORD-1]}
  11. case "$prev" in
  12. -f)
  13. FORMATTERS=`pygmentize -L formatters | grep '* ' | cut -c3- | sed -e 's/,//g' -e 's/:$//'`
  14. COMPREPLY=( $( compgen -W '$FORMATTERS' -- "$cur" ) )
  15. return 0
  16. ;;
  17. -l)
  18. LEXERS=`pygmentize -L lexers | grep '* ' | cut -c3- | sed -e 's/,//g' -e 's/:$//'`
  19. COMPREPLY=( $( compgen -W '$LEXERS' -- "$cur" ) )
  20. return 0
  21. ;;
  22. -S)
  23. STYLES=`pygmentize -L styles | grep '* ' | cut -c3- | sed s/:$//`
  24. COMPREPLY=( $( compgen -W '$STYLES' -- "$cur" ) )
  25. return 0
  26. ;;
  27. esac
  28. if [[ "$cur" == -* ]]; then
  29. COMPREPLY=( $( compgen -W '-f -l -S -L -g -O -P -F \
  30. -N -H -h -V -o' -- "$cur" ) )
  31. return 0
  32. fi
  33. }
  34. complete -F _pygmentize -o default pygmentize