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