0

This question already has an answer here:

I have a simple script to print color text in terminal which I've directed to log file too.

#!/bin/bash

echo -e "\033[01;32mGreen color" > ~/Desktop/color.log

When I run from terminal cat color.log, it prints with green color but when I open file with gedit it shows as

[01;32mGreen color

Is it possible to redirect with color in gedit?

marked as duplicate by terdon bash Sep 25 '18 at 10:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

Most probably not. There might be an option or a plugin in gedit that allows it to interpret this sort of ANSI color escape code, but that's unlikely since the point of those codes is to display color in terminal-based tools, not a GUI tool like gedit.

I suggest you simply use a terminal based tool to read your files instead. For example, you can use less -R which can interpret color codes correctly:

less -R  ~/Desktop/color.log
  • Your answer is somewhat useful but not this answer as it does not fulfill my requirement and you also said the point of those codes is to display color in terminal-based tools, not a GUI tool like gedit. Yes. I agree, question is similar but not an answer. – d a i s y Sep 25 '18 at 11:31
  • @daisy I don't understand, the other question seems to be asking for exactly the same thing you are: for a way to show ansi escapes as colors in gedit. What is the difference? The basic answer is no, that isn't possible. – terdon Sep 25 '18 at 11:33
  • okay. The basic answer is no, that is not possible -I should have known better. – d a i s y Sep 25 '18 at 12:08
  • 1
    Well… not until someone write a GEdit extension that achieves this but I’m unaware of any existing solutions. – David Foerster Sep 25 '18 at 12:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.