walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
587 stars 17 forks source link

Allow explicitly specifying filetype #134

Closed mjholub closed 6 months ago

mjholub commented 1 year ago

We all often pipe something from STDOUT to a pager. The output can often be in a json format (e.g. from a logger) or a shell script (though I'm not sure if moar simply looks for a shebang in such instances, since many script files don't necessarily contain an extension), and therefore it'd be really useful if instead of first writing the output to a temporary file or rename the files, be able to explicitly set the filetype in moar, similar to using set ft in Vim.

walles commented 1 year ago

Hello!

Regarding JSON, I think piping through jq might be even better, since that would give you formatting as well:

echo '{"url":"https://github.com/walles/riff"}' | jq -C | moar

Except for JSON, what other file types do you tend to read from scripts?

mjholub commented 1 year ago

well, that'd be mostly it, thanks for the jq hack, although one example I can think of are OpenRC service files, which use shell script syntax, but have no file extensions. Same goes for some scripts that are added to $PATH and for convenience also use no extension, e.g. neofetch. Same with some python, perl, ruby or node standalone scripts that may e.g. just specify their interpreter on the first line.

Some markdown, yaml or config files may also not always have an extension.

walles commented 1 year ago

Except for JSON, how often have you actually been missing this?

Enough that you'd have manually specified a MIME type on the command line?

This could be implemented, but I'm unsure how much use it would actually see.

walles commented 6 months ago

Just released v1.21.0 where you can use the -lang option for telling the highlighter about the input file language.