Merge pull request #1428 from markusdd/patch-1

Update less-pretty-cat plugin to support pygment style selection
pull/1431/head
Nils Winkler 2019-10-08 08:50:11 +02:00 committed by GitHub
commit 440ca7456f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,8 @@ if $(command -v pygmentize &> /dev/null) ; then
# get the full paths to binaries
CAT_BIN=$(which cat)
LESS_BIN=$(which less)
BASH_IT_CCAT_STYLE="${BASH_IT_CCAT_STYLE:=default}"
BASH_IT_CLESS_STYLE="${BASH_IT_CLESS_STYLE:=default}"
# pigmentize cat and less outputs - call them ccat and cless to avoid that
# especially cat'ed output in scripts gets mangled with pygemtized meta characters
@ -15,7 +17,7 @@ if $(command -v pygmentize &> /dev/null) ; then
example 'cat mysite/manage.py dir/text-file.txt'
for var;
do
pygmentize "$var" 2>/dev/null || "$CAT_BIN" "$var";
pygmentize -f 256 -O style="$BASH_IT_CCAT_STYLE" -g "$var" 2>/dev/null || "$CAT_BIN" "$var";
done
}
@ -24,6 +26,6 @@ if $(command -v pygmentize &> /dev/null) ; then
about 'it pigments the file passed in and passes it to less for pagination'
param '$1: the file to paginate with less'
example 'less mysite/manage.py'
pygmentize -g $* | "$LESS_BIN" -R
pygmentize -f 256 -O style="$BASH_IT_CLESS_STYLE" -g $* | "$LESS_BIN" -R
}
fi