1
ls -la # This gives a coloured output.

But,

puts %x{ ls -la } # The colours aren't preserved here.

Is there a way to get coloured output??

Jikku Jose
  • 18,306
  • 11
  • 41
  • 61
  • try `ls --color=always` – John C Jun 10 '14 at 02:13
  • Worked perfectly for me. – John C Jun 10 '14 at 06:45
  • I don't see colours on OSX I tested it on linux. – John C Jun 10 '14 at 07:45
  • For OSX you need `CLICOLOR_FORCE=1 ls -G` – John C Jun 10 '14 at 08:11
  • Wow! That worked! Can you post that as answer, will mark it as the correct answer. – Jikku Jose Jun 10 '14 at 08:14
  • I would but @sawa has marked your question as a duplicate. :-( Can you please change this? It's a good question, and I need more points! :0) – John C Jun 10 '14 at 08:15
  • How can I refute the this question is not a duplicate? I don't think its duplicate. – Jikku Jose Jun 10 '14 at 08:26
  • @JikkuJose Put something in the question statement that clearly shows why this isn't the same question. Something like " does not solve the issue because it deals with when I'm having trouble with ". You don't have to use my exact wording, but make it clear to others in your question statement why these are two different problems. – Dennis Meng Jun 16 '14 at 03:12
  • possible duplicate of [Color output from shell command in Ruby](http://stackoverflow.com/questions/948359/color-output-from-shell-command-in-ruby) – spuder Sep 25 '14 at 19:31

0 Answers0