Search This Blog

Pimp my LESS

Ever found yourself browsing through some old legacy sources in some forsaken remote server with less? well, here’s a small tip you can use to make the experience not so bad. make less do more for you :)

first, make sure you have pygments installed:

user@pc:~$ sudo apt-get install python-pygments

then, just dump a small script somewhere on your path (I use ~/bin/lezz):

#! /bin/sh
[ $# -ge 2 -a -f "$2" ] && input="$2" || input=""
pygmentize -l $1 -f terminal256 -O full,style=monokai $input | less -R

yo dawg  

and that’s it. now you can use it like:

lezz [lang] [file]

# or recieve from stdin
cat [file] | lezz [lang]


user@pc:~$ lezz bash `which lezz`
user@pc:~$ cat `which lezz` | lezz sh

if you don’t like the style, change it. instead of monokai you can use any style under:

user@pc:~$ pygmentize -L style