Lots of programming-oriented editors will colorize source code. Is there a command that will colorize source code for viewing in the terminal?
I could open a file with emacs -nw
(which opens in the terminal instead of popping up a new window), but I'm looking for something that works like less
(or that works with less -R
, which passes through color escape sequences in its input).
Best Answer
With
highlight
on a terminal that supports the same colour escape sequences asxterm
:With
ruby-rouge
:With
python-pygments
:With GNU
source-highlight
:You can also use
vim
as a pager with the help ofmacros/less.sh
script shipped withvim
(see:h less
withinvim
for details):On my system:
Or you could use any of the syntax highlighters that support HTML output and use
elinks
orw3m
as the pager (orelinks -dump -dump-color-mode 3 | less -R
) like with GNUsource-highlight
: