Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow explicitly specifying filetype #134

Closed
mjholub opened this issue May 7, 2023 · 5 comments
Closed

Allow explicitly specifying filetype #134

mjholub opened this issue May 7, 2023 · 5 comments

Comments

@mjholub
Copy link

mjholub commented May 7, 2023

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
Copy link
Owner

walles commented May 20, 2023

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
Copy link
Author

mjholub commented May 22, 2023

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
Copy link
Owner

walles commented May 28, 2023

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
Copy link
Owner

walles commented Jan 4, 2024

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

@walles
Copy link
Owner

walles commented Sep 10, 2024

Even better, in this release JSON coming from pipes is auto detected and highlighted accordingly:

https://github.com/walles/moar/releases/tag/v1.27.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants