Commits

Georg Brandl committed bfb51e4

Added a bash completion script for `pygmentize`, to the external/ directory (#466).

Comments (0)

Files changed (3)

 
 - Added support for PHP 5.3 namespaces in the PHP lexer.
 
+- Added a bash completion script for `pygmentize`, to the external/
+  directory (#466).
+
 - Fixed a bug in `do_insertions()` used for multi-lexer languages.
 
 - Fixed a Ruby regex highlighting bug (#476).

docs/src/integrate.txt

 colorize code via a simple menu option.  It can be found here_.
 
 .. _here: http://antoniocangiano.com/2008/10/28/pygments-textmate-bundle/
+
+Bash completion
+---------------
+
+The source distribution contains a file ``external/pygments.bashcomp`` that
+sets up completion for the ``pygmentize`` command in bash.

external/pygments.bashcomp

+#!bash
+#
+# Bash completion support for Pygments (the 'pygmentize' command).
+#
+
+_pygmentize()
+{
+    local cur prev
+
+    COMPREPLY=()
+    cur=`_get_cword`
+    prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    case "$prev" in
+        -f)
+            FORMATTERS=`pygmentize -L formatters | grep '* ' | cut -c3- | sed -e 's/,//g' -e 's/:$//'` 
+            COMPREPLY=( $( compgen -W '$FORMATTERS' -- "$cur" ) )
+            return 0
+            ;;
+        -l)
+            LEXERS=`pygmentize -L lexers | grep '* ' | cut -c3- | sed -e 's/,//g' -e 's/:$//'` 
+            COMPREPLY=( $( compgen -W '$LEXERS' -- "$cur" ) )
+            return 0
+            ;;
+        -S)
+            STYLES=`pygmentize -L styles | grep '* ' | cut -c3- | sed s/:$//`
+            COMPREPLY=( $( compgen -W '$STYLES' -- "$cur" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '-f -l -S -L -g -O -P -F \
+                                   -N -H -h -V -o' -- "$cur" ) )
+        return 0
+    fi
+}
+complete -F _pygmentize -o default pygmentize