Merge pull request #1428 from markusdd/patch-1
Update less-pretty-cat plugin to support pygment style selectionpull/1431/head
commit
440ca7456f
|
|
@ -5,6 +5,8 @@ if $(command -v pygmentize &> /dev/null) ; then
|
||||||
# get the full paths to binaries
|
# get the full paths to binaries
|
||||||
CAT_BIN=$(which cat)
|
CAT_BIN=$(which cat)
|
||||||
LESS_BIN=$(which less)
|
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
|
# 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
|
# 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'
|
example 'cat mysite/manage.py dir/text-file.txt'
|
||||||
for var;
|
for var;
|
||||||
do
|
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
|
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'
|
about 'it pigments the file passed in and passes it to less for pagination'
|
||||||
param '$1: the file to paginate with less'
|
param '$1: the file to paginate with less'
|
||||||
example 'less mysite/manage.py'
|
example 'less mysite/manage.py'
|
||||||
pygmentize -g $* | "$LESS_BIN" -R
|
pygmentize -f 256 -O style="$BASH_IT_CLESS_STYLE" -g $* | "$LESS_BIN" -R
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue