From 0f64861cf3e2f8ecbb60775bfd67f17779ba1506 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 1 Mar 2010 17:32:47 +0100 Subject: Added a bash completion script for `pygmentize`, to the external/ directory (#466). --- CHANGES | 3 +++ docs/src/integrate.txt | 6 ++++++ external/pygments.bashcomp | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 external/pygments.bashcomp 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 -- cgit v1.2.1