summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-03-01 17:32:47 +0100
committerGeorg Brandl <georg@python.org>2010-03-01 17:32:47 +0100
commit0f64861cf3e2f8ecbb60775bfd67f17779ba1506 (patch)
treedfeb0d21f7edfd269785341c5c8b4c1ae06c535b
parent224db4ea8cdeee9b86e0264496b5d6f55cdce216 (diff)
downloadpygments-0f64861cf3e2f8ecbb60775bfd67f17779ba1506.tar.gz
Added a bash completion script for `pygmentize`, to the external/ directory (#466).
-rw-r--r--CHANGES3
-rw-r--r--docs/src/integrate.txt6
-rw-r--r--external/pygments.bashcomp38
3 files changed, 47 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index b729d0ca..6ce9891a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,9 @@ Version 1.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).
diff --git a/docs/src/integrate.txt b/docs/src/integrate.txt
index fb3fa5a0..51a3dac4 100644
--- a/docs/src/integrate.txt
+++ b/docs/src/integrate.txt
@@ -35,3 +35,9 @@ Antonio Cangiano has created a Pygments bundle for TextMate that allows to
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.
diff --git a/external/pygments.bashcomp b/external/pygments.bashcomp
new file mode 100644
index 00000000..1299fdb9
--- /dev/null
+++ b/external/pygments.bashcomp
@@ -0,0 +1,38 @@
+#!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