Using bash
on Mac OS to edit some man
pages for my own use.
In Mac OS the command open -t filename
will open the specified file in the system's default text editor.
$ man somepage | col -b
will properly render the designated man
page. What I want to do is open the rendered man page in the text editor. I can accomplish this as follows:
man somepage | col -b > filename && open -t filename
I should probably be happy with that, but I got it in my brain that there must be a "better way" to do this using only piping and redirect. Also, the command above tends to "litter" my file system with files that I may not need to retain - and therefore requires another step to delete the cruft. Ideally, I could open the rendered man page in the editor without a file name, or some generic filename that would be overwritten on each invocation. I've spent about an hour now noodling over this, trying different things, to no avail.
What made most sense to me was this:
$ open -t < man somepage | col -b
or this:
$ open -t &1 < man somepage | col -b
but of course that doesn't work because the shell takes man
as the filename. Am I even close to getting this right? Am I daft for trying?
open -t <(man somepage | col -b)
, but that doesn't actually work because of the way bothopen
and TextEdit behave. – Michael Homer Sep 03 '18 at 04:39man open
intently while trying to get this to work, but glossed over this (-f
option) probably 5 times... as Obi-Wan said, "We see what we want to see..." OWTTE – Seamus Sep 03 '18 at 16:34open -t <(...)
) doesn't work here is the same as in this answer to Why does BASH process substitution not work with some commands?. In short, the editor would get a/dev/fd/N
that looks like a file but it's in fact a pipe. Editors (even if they're happy taking piped input from stdin) are not always happy with piping through process substitution fds. – filbranden Sep 03 '18 at 16:53open
doesn’t actually start the program as a child, it asks the operating system to spawn it and terminates. There’s no relationship between the two processes to preserve the file descriptors; onceopen
terminates so does the pipeline, and nothing has a chance to see the contents first. TextEdit only accepts regular files, but even if you have a different default editor that is happy with the file name it won’t help still because it will never get the chance to use it. – Michael Homer Sep 03 '18 at 18:54