Skip to main content
15 events
when toggle format what by license comment
Jul 22 at 2:15 history edited Pablo A CC BY-SA 4.0
Improved formatting. Minor fixes.
May 30, 2022 at 17:08 comment added Ti Strga FINALLY! Utúvienyes! I have been scouring Teh Intartubez for something that would strip ANSI color escapes (easy) and also the tput sgr0 terminal sequences (largely ignored by SO). Couldn't find or evolve a tr sequence that would catch the latter without destroying all other input. Thank you muchly!
Jun 11, 2018 at 9:07 comment added Chris Stryczynski That makes sense. I used the following sed command to insert line breaks. sed -r 's/^(.{0,98})(.*)/\1\n\2\n/' where 98 in the column width of the terminal (tput cols).
Jun 11, 2018 at 8:53 comment added Gilles 'SO- stop being evil' @ChrisStryczynski It does if they use line feeds. It doesn't if they use cursor motion commands, which they typically would when repainting the screen. Removing terminal commands is the whole point of the script.
Jun 10, 2018 at 13:28 comment added Chris Stryczynski This does not seem to preserve line breaks in applications that output to vty (like less / vim).
Jun 10, 2018 at 0:08 comment added Gilles 'SO- stop being evil' @Jeffrey You're right. Many VTxxx terminals historically interpreted bytes in the range 128–159 as control characters but most terminal emulators these days don't and I've never seen them used for markup in files meant to be displayed on a terminal. I've edited my answer to show a version that lets non-ASCII characters through unchanged.
Jun 10, 2018 at 0:06 history edited Gilles 'SO- stop being evil' CC BY-SA 4.0
as Jeffrey notes, non-ASCII characters are probably not meant to be control characters, so present a version that lets them through first
Jun 9, 2018 at 4:52 comment added Jeffrey This mangles multibyte characters such as ☺ (\xe2 \x98 \xba). The [\x80-\x9f] clause strips the middle byte.
Jan 5, 2018 at 20:31 comment added Gilles 'SO- stop being evil' @TrevorBoydSmith Either will work for input, and the output is always on standard output, like typical text utilities.
Jan 5, 2018 at 17:14 comment added Trevor Boyd Smith please provide how to use this script. does it require pipe input? or positional arguments?
Jun 27, 2016 at 22:51 history edited Gilles 'SO- stop being evil' CC BY-SA 3.0
added search fodder
Jun 16, 2011 at 13:53 comment added Gilles 'SO- stop being evil' @andrew: My regexp is flexible enough that I expect it to work with pretty much any now-existing terminal, and probably with any tomorrow-existing terminal as well. I haven't tested it much, so there might be bugs, but the approach is sound as control sequences follow a few general patterns.
Jun 16, 2011 at 12:49 comment added andrew cooke thanks to both answers. i felt i should make something as a good answer, although both give regexps, which i wanted to avoid. chose this one as it gives a reference for the format.
Jun 16, 2011 at 12:48 vote accept andrew cooke
Jun 9, 2011 at 20:43 history answered Gilles 'SO- stop being evil' CC BY-SA 3.0