RubyFlow The Ruby and Rails community linklog

Syntax highlighting in the terminal with ruby

I made a little script to read ruby files and spit them out coloured in the terminal. It can be used to replace cat eventually so that you can see the line number and highlighting. It only highlights ruby at the moment and highlights in aweful hard coded colours, but that’s easy to change. Future features could also include highlighting search strings passed through the second parameter.

Comments

cool script - did you consider src-highlight + less?

thanks I never saw that.

I would like to highlight search results in the script eventually and also give out sed hints though.

Another Way is to use the coderay gem, which also installs an executable. You can simply call coderay source.rb to get a nice and colorful output :)

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in