Search This Blog


Showing posts with label highlight. Show all posts
Showing posts with label highlight. Show all posts

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]

e.g.

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

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

user@pc:~$ pygmentize -L style

Blog.init();

Ok, first post. WOOHOOO! Just finished setting up everything: syntax highlighting & markdown. a little example (taken from here which I pimped up a bit) shows it:

Syntax highlighting is fun!

HTML

    <h1>HTML code</h1>
    <div class="some">This is an example</div>

Python

    def func():
      for i in [1, 2, 3]:
        print "%s" % i

Scala

    def fib(a: Int, b: Int): Stream[Int] = a #:: fib(b,a+b)
    fib(1,1).filter(_ % 2 == 0).take(10).toList

Java (deprecated)

    class HelloWorldApp {
      public static void main(String[] args) {
        System.out.println("Hello World!"); // Print the string to the console.
      }
    }

highlighting is done with highlight.js & markdown with pagedown extra

So, I’ll probably babble here about all kind of things I find interesting. Also, as the name says, I’m open to suggestions (So my wife just came up with a cool name… IM KEEPING IT!). apparently, coming up with a name for your blog, is quite hard…

anyway, hope to have some fun. see ya’ :)