As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label escape code. Show all posts

tl;dr:


man ascii(7)
man console_codes(4) # for ANSI escape code

I was looking around and stumbled on this man ascii and I was like dumbfounded, wondering how I could not have known about this.

Why? Because I searched for the Wikipedia pages for ASCII and ANSI escape code. Maybe rarely for ASCII character codes, but quite often for the escape codes whenever I was writing a shell script that would need to move cursor or clear screen, such as blocky.sh.

How I found console_codes, since it doesn’t have “ANSI” nor “escape” in the title? I searched with [manpage ansi escape code] for a manual page and found that on the first hit. I couldn’t believe that I used to go to Wikipedia for those codes, when they are already on my disk all along.

It’s funny to think about there is nearly everything on the Internet, the knowledge is vast if you are willing to read, but you don’t have to go out to the virtual world, there already is plenty for us to digest inside our computers.

It’s like human on Earth, and the universe seems without edges if you consider our knowledge, engineering, and capabilities, but the facts are that we don’t even learn a fraction of the planet we are living on, the truth is that we don’t even know everything about ourselves, our human body.

From man man:
man foo | col -b > foo.mantxt
It doesn't work for me, this what I got:
1mNAME0m
       bash - GNU Bourne-Again SHell

1mSYNOPSIS0m
       1mbash 22m[options] [file]

\033[ were removed but the rest of escape code still there. I am not sure why those escape code were modified by col. Anyway, col is obvious not what I need.

I don't want escape code to emphasize text. I want a really plain text output. I tried to read more about man, groff, whatever in man's manpage... I wasn't sure how a manpage being generated.

The easiest workaround is to remove escape code by myself:
man bash | sed $'s/\033\[[^m]*m//g' > bash.txt
(It's still some non-printing chars in the output, run with cat -v)

I still need: setting text width of output or no wrapping.

Updated:  This would do ( echo ".ll 11.5i"; echo ".nr LL 11.5i"; echo ".pl 1100i"; /bin/bzip2 -c -d "/usr/share/man/man1/bash.1.bz2"; echo ".\\\""; echo ".pl \n(nlu+10" ) | /usr/bin/gtbl | /usr/bin/nroff -mandoc | sed $'s/\033\[[^m]*m//g' > bash.txt
. The numbers control the width, but I don't have any idea how to calculator them from text width I need.