[rspec-users] Color output in pagers

Paul Hinze paul.t.hinze at gmail.com
Wed Dec 2 10:40:15 EST 2009


P. A. <lists at ruby-forum.com> on 2009-12-02 at 09:08:
> Is it possible to get color text in less, more or other pagers while
> piping the color output of Cucumber and RSpec?

Have a look at these options for `less`:

>From LESS(1) man page:
> -r or --raw-control-chars
> 
>       Causes "raw" control characters to be displayed.  The default is to
>       display control characters using the caret notation; for example, a
>       control-A (octal 001) is displayed as "^A".  Warning: when the -r
>       option is used, less cannot keep track of the actual appearance of
>       the screen (since this depends on how the screen responds to  each
>       type of control character).  Thus, various display problems may
>       result, such as long lines being split in the wrong place.
> 
> -R or --RAW-CONTROL-CHARS
> 
>       Like  -r,  but  only ANSI "color" escape sequences are output in
>       "raw" form.  Unlike -r, the screen appearance is maintained correctly
>       in most cases. 

You can set default options for less to use via the LESS evironment variable.
As an example, here is the value of mine:

$ echo $LESS
-X -e -R

Cheers,

Paul


More information about the rspec-users mailing list