mkfifo -m600 name.pipe
nc -lkU aSocket.sock
Getting a pty master from command line1
To run cmd
connected to a pty which you can access the master side:
script -c cmd logfile | cat
unbuffer [-p] cmd | cat
Redirecting man
to a non-tty causes it to dump perfectly formated plain text,
sized to the current screen width. From inspecting
strace -f -o trace.out -e execve man page > page.txt
# (-f = follow child processes; necessary to see `execve` syscalls).
I could reproduce using the source doc and *roff pipelines.
export GROFF_SGR=1 # undoc. requirement for ANSI tty formatting in output.
# /usr/share/groff/site-tmac/man.local (Arch-specific?)
# Each of these is (seemingly) equivalent:
zcat page.1.gz | preconv [-e utf-8] | tbl | troff -man -Tutf8 | grotty
... | preconv | ... | nroff -man
... | groff -kt -man -Tutf8
man
is a "macro package" for authoringroff
manpages.troff
is the primary device-independent formatter.nroff
is a wrapper for text/tty output (-Tutf8 specifies a "device")grotty
implements the tty output device.nroff
always uses it.preconv
converts all input to plain ascii and\[uXXXX]
sequences. The roff programs require this. Uses system locale by default.tbl
is a preprocessor for tables.eqn
for math, ...groff
is the newer front end.-k -t
takes care ofpreconv
andtbl
unset GROFF_SGR # system-specific; see above.
zcat page.1.gz | preconv | ... | troff -man -Tutf8 | grotty -cbou
... | groff -kt -man -Tutf8 | col -xb
-
Output mode should be non-SGR. i.e., using overstrike sequences instead of ANSI escape sequences for formatting.
grotty -c
is one way; settingGROFF_NO_SGR
is another.- Locally, it's actually the default when
GROFF_SGR
isn't specifically set. But that appears to be Arch-specific.
-
However, the overstrike sequences still need to be suppressed or removed.
-b -o -u
options togrotty
appear to do the trick.col
at the end of the pipeline can do it as well.
The -rLL={XX}n -rLT={XX}n
options to [tg]roff
set the column width. man
appears to query the tty for this info every time it renders a page.
tmux
command:
capture-pane [-p] [-t pane] [-S n -E n]
save-buffer <filename>
- p = send to stdout (not to be used from attached client)
- S and E = start/end lines (default is visible screen)
(0 = first line of visible screen; neg. numbers = history)
cmark-gfm notes.md | w3m -T text/html
glow file.md
lowdown -tterm file.md
lowdown
has several output targets besides term
:
lowdown -st{ms,man,latex,html} file.md
lowdown -stms ... | groff -tk -mspdf -Tutf8
lowdown -stman ... | groff -tk -man -Tutf8
lowdown -stman ... | mandoc
The -s
is critical for those pipelines; it generates a standalone document
instead of a fragment.