Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

less color is more color

Alex Chaffee
Saturday, February 10, 2007

Ever do “less log/development.log” and see the following?

ESC[4;35;1mSQL (0.001084)ESC[0m ESC[0mSET character_set_results = utf8;ESC[0m
ESC[4;36;1mSQL (0.001792)ESC[0m ESC[0;1mSHOW TABLESESC[0m

Wouldn’t it be nicer to see the colorization like when you’re tailing the log with tail -f? Try using -R:

less -R log/development.log

Then you’ll see

SQL (0.001084) SET character_set_results = utf8;
SQL (0.001792) SHOW TABLES

A bit more legible, eh wot old chaps?

Works on Mac and Cygwin too.

And -X makes it not clear the screen when you stop less, so you get to keep seeing what you were just seeing.

So that means you may want to put

alias less="less -RX"

or

export LESS="-RX"

in your .bash_profile.

Also, if you don’t want the fancy colors at all, specify

ActiveRecord::Base.colorize_logging = false

in your environment file (e.g. test.rb.) We’re doing that in our test.rb so we can more clearly read the output from our CruiseControl build.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Add New Comment Cancel reply

Your email address will not be published.

Alex Chaffee

Recent Posts

  • Code Monkey
  • RubyGems Warningitis Outbreak
  • Upgrading your Rakefile from RSpec 1.3 to RSpec 2
Subscribe to Alex's Feed

Author Topics

ruby (14)
gem (5)
ruby on rails (24)
erector (2)
rspec (4)
activerecord (4)
database (3)
sinatra (1)
postgresql (1)
css (1)
html (1)
git (2)
mac (5)
java (3)
agile (12)
iphone (1)
migrations (1)
fun (5)
dot (1)
graphing (1)
subversion (1)
test (1)
demeter (1)
puzzler (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >