blob: d52e95c4995040d3914b5d4dd231ffced20edd61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# easier alias to use the plugin
alias ccat='colorize_via_pygmentize'
colorize_via_pygmentize() {
if ! (( $+commands[pygmentize] )); then
echo "package 'Pygments' is not installed!"
return 1
fi
# pygmentize stdin if no arguments passed
if [ $# -eq 0 ]; then
pygmentize -f terminal -g
return $?
fi
# guess lexer from file extension, or
# guess it from file contents if unsuccessful
local FNAME lexer
for FNAME in $@
do
lexer=$(pygmentize -N "$FNAME")
if [[ $lexer != text ]]; then
pygmentize -f terminal -l "$lexer" "$FNAME"
else
pygmentize -f terminal -g "$FNAME"
fi
done
}
|