lessmd icon indicating copy to clipboard operation
lessmd copied to clipboard

bin usage: render with pager when piping from stdin

Open junosuarez opened this issue 7 years ago • 0 comments

in https://github.com/linuxenko/lessmd/blob/1076ecf79c845c66f8eba8a5deaa1c0fbf6172a5/bin/lessmd#L34 the program flushes the rendered text and then exits when the data was piped from stdin OR when stdout is not an interactive terminal (isPipe || !process.stdout.isTTY)

in practice, this means that I have to do something like cat foo | lessmd | less (bring my own pager) but what I'd like to be able to do is just cat foo | lessmd

One option would be simply to change this conditional. This might break some people's workflows, if that's a concern (although I can't think of any, since piping from stdout would still work without the rendered header / footer).

Another option would be to use the pager behavior if piping from stdin AND specifying - as the file name, e.g. cat foo | lessmd -. Currently, that prints no such file -. - is commonly used in other linux cli tools to indicate stdin, as I'm sure you're aware.

A third option would be to add an explicit flag to require the pager, or conversely, an explicit flag to suppress the pager: echo hi | lessmd --pager echo hi | lessmd --no-pager or some other convention.


thanks for all your hard work on this package, it's very useful! I intend to feature this package on awesome-npx

junosuarez avatar Jul 12 '17 20:07 junosuarez