Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to pipe the output of a script (Mocha) to another script. However there is one problem: Mocha generates quite a few ansi escape characters to update the screen on the fly. These characters are also send through the pipe.

Is there a way to process the ansi sequence such that the output is the same as the final output to the screen? I do want to keep color escape sequences, but not the curser movement escapes.

Edit: I have a partial solution now (for Mocha only): so far it seems that Mocha with the spec output (the one I use) only generates color ecape characters and the CSI 0G escape sequence. The CSI 0G escape character means that the cursor should move back to the beginning of the line. Mocha uses this to overwrite a line completely. Therefore you could simply create a sed regexp which will delete everything up to that escape sequence on a line: sed 's/^.*\x1b\[0G//g'. I am still looking for the complete solution though.

share|improve this question
    
The same question exists here stackoverflow.com/questions/6306728/… –  zmode Oct 17 '12 at 20:50
    
@zmode that's not the identical, that one is about removing all ansi codes, whereas here the OP wants to "keep color escape sequences" –  eis Oct 17 '12 at 20:55
    
@Tiddo Do you know how the other script would handle the color escapes? it would sound peculiar that it could handle them... –  eis Oct 17 '12 at 21:02
    
@eis - The other script is ansifilter. It generates colored HTML from ansi input. By design it is able to handle color escapes, but for some reason it can't handle the movement escape characters. –  Tiddo Oct 17 '12 at 21:36
    
@Tiddo ok, makes sense. –  eis Oct 18 '12 at 8:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.