LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-19-2017, 04:04 AM   #16
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,147
Blog Entries: 9

Rep: Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603

Quote:
Originally Posted by mintzyuval View Post
I have logs produced by programs that print to the terminal with colors using escape sequences.

I usually use VIM (or gvim) to open logs, but seeing all those escape sequences instead of colors really bother me.

Is there a way to set VIM to use esacape-sequences (as opposed of showing them on screen)? if not, do you happen to know a solid text-editor that can do that?
i presume you do not need to edit these files.
why not just use that which is best at interpreting the ansi sequences - the terminal itself?
you could write yourself a simple one-liner script that would invoke a terminal just to look at the file.
e.g.:
Code:
urxvt -e sh -c "cat \"$1\"; tput setaf 1; read -p 'Press Enter to close this window.'"
i already added a red fancy prompt. now you can influence the urxvt command for font type & size, window size & position etc.
should be sufficient?
 
Old 11-19-2017, 04:43 AM   #17
miriam-e
LQ Newbie
 
Registered: Nov 2011
Location: QLD, Australia
Distribution: Puppy Linux
Posts: 29

Rep: Reputation: Disabled
Interesting idea, ondoho, and thanks for the suggestion.
For simply displaying ANSI styled text I'd use
Code:
less -R textfile
I actually wanted to be able to edit the files though. I think the original poster wanted to too.
 
Old 11-19-2017, 03:39 PM   #18
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,147
Blog Entries: 9

Rep: Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603Reputation: 3603
Quote:
Originally Posted by miriam-e View Post
I actually wanted to be able to edit the files though. I think the original poster wanted to too.
it doesn't make sense.
who ever wanted to edit log ifles?

and anyhow, in the end you'd be needing 2 separate views, one where you see the end result, and one where you can edit the "tags" (escape sequences);
or some sort of Wysiwig like on the forums here, with loads of buttons and dropdown menus... of course it's possible, but why?
 
Old 11-19-2017, 04:34 PM   #19
miriam-e
LQ Newbie
 
Registered: Nov 2011
Location: QLD, Australia
Distribution: Puppy Linux
Posts: 29

Rep: Reputation: Disabled
ondoho, I don't want it for editing log files, but I can imagine situations where someone might want to edit a logfile to remove all the irrelevant parts and just keep the ones relating to some particular problem or experiment they're doing. Or perhaps they might want to highlight certain parts.

Wysiwyg editors are what I was looking for, and listed a few initial examples of. SyncDraw is the best I've found so far, though I'm still dissatisfied and searching for a better one.

For me, being able to edit ANSI text files is really useful. I had an example just this morning. On the bug-gawk email list yesterday someone suggested a simple way to visually check how a regular expression works:

grep -E --color 'pattern'

It's a really neat quick guide to help debug some patterns. As an example try the pattern 'j{1,3}as' on the text file:
Code:
jas
jjasd
jjjasd
jjjjasd
jjjjjasd
Then try it again, but this time anchoring the expression to the beginning of each line '^j{1,3}as'

Because output is in color, if I want to make notes for myself about it (I make notes for myself about everything) then I have to either make my notes using ANSI text or HTML. HTML seems like overkill, especially since the original is in ANSI anyway.

More on your solution above for viewing ANSI text... it actually does a better job of displaying ANSI text than my suggestion of "less -R" does because the latter annoyingly resets the ANSI codes at the end of every line. Also "less -R" ignores position codes that are used in some ANSI art. So, thanks again for your suggestion.

Last edited by miriam-e; 11-19-2017 at 05:09 PM.
 
1 members found this post helpful.
Old 11-19-2017, 10:48 PM   #20
notmeagin
LQ Newbie
 
Registered: Nov 2017
Posts: 6

Rep: Reputation: Disabled
Wink Reply

I have used ansi escape codes i .bat files under DOS & Windows so I would guess you could do the same with a bash file under Linux. If so a basic text editor would work. personally I like the Midnight Commander's text editor.
 
Old 11-20-2017, 01:02 AM   #21
miriam-e
LQ Newbie
 
Registered: Nov 2011
Location: QLD, Australia
Distribution: Puppy Linux
Posts: 29

Rep: Reputation: Disabled
notmeagin, yep, I often include ANSI escape codes in my scripts. At the moment I do it exactly as you say, in a standard text editor (usually either leafpad or geany), but it would be nice to be able to enter colored or bold or underlined or italic text directly into the editor without having to constantly look up the codes and type them in. That is, using a wysiwyg (what you see is what you get) editor. SyncDraw does this to some degree, but has some deficiencies that make it pretty unusable for me.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Less outputs ANSI escape sequences sprocketboy Mandriva 2 08-05-2009 09:22 PM
escape sequences in enscript lanco Linux - Newbie 1 03-01-2009 03:32 PM
LXer: CLI Magic: Use ANSI escape sequences to display a clock in your terminal LXer Syndicated Linux News 0 01-22-2008 11:20 PM
How to stop terminal escape sequences ? Mike Davies Linux - Newbie 1 08-08-2004 12:37 PM
Xterm escape sequences GrayGh0st Linux - Software 3 07-19-2003 01:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration