walles / moar

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

moar style switch seems broken and not working #159

Closed ciscohack closed 1 year ago

ciscohack commented 1 year ago

I have tried moar --style=gruvbox and suppose that moar will render the color format in gruvbox theme but it seems not working and moar is using default terminal theme color style for moar.. Running latest moar version on macOS sonoma 14.0 version. Ideally it should use the terminal theme style only when no --style switch option used along with moar

image
ciscohack commented 1 year ago

one more thing this help section also seems showing the wrong switch like it showing (-style) but if I am correct it should be (--style)

walles commented 1 year ago

Works for me with moar v1.17.0 in the macOS terminal.

  1. Can you try this in the macOS terminal? To rule out any terminal related configuration on your side?
  2. What does echo $MOAR say?
  3. What does echo $TERM say?

moar --style=gruvbox moar.go:

moar-gruvbox

moar moar.go:

moar-default-style
mtvrsh commented 1 year ago

one more thing this help section also seems showing the wrong switch like it showing (-style) but if I am correct it should be (--style)

Both flags are accepted and correct, -style is just printed by default. See this link for reference.

ciscohack commented 1 year ago

@walles @m3tav3rse Thanks for your comment and input. I don't know why but it's not working for me

John here is output of value you requested

image
walles commented 1 year ago

If you have MOAR=--style=gruvbox and run these two commands, then both of them will use the Gruvbox theme:

  1. Can you post screenshots of moar --style=igor vs moar --style=gruvbox?
  2. Can you post, in a copy-pasteable format, the exact command lines you use?
ciscohack commented 1 year ago

here is the output of commands

moar --style=igor asa.log

image

moar --style=gruvbox asa.log

image
walles commented 1 year ago

There is no highlighting for .log files, so the theme doesn't matter.

Ref: https://github.com/walles/moar/issues/128#issuecomment-1453754629

ciscohack commented 1 year ago

I didn't get it. Do you mean to say the style color only works with programming files and for the rest other file types like txt and log, use the terminal color. but BAT has no such limit.. it can render color style for any file whatever I choose But yes syntax highlight will work only for programming files. I expect same with moar ... request you to add this if missing

Not asking to highlight syntax through BAT support but at least color change for file I parse in moar

walles commented 1 year ago

[BAT] can render color style for any file whatever I choose But yes syntax highlight will work only for programming files

"Syntax highlight" is what moar provides through Chroma (I think).

But what is "color style"? And how is that different from syntax highlight?

Maybe if you have a screenshot of what you'd expect then that could clarify this?

ciscohack commented 1 year ago

so I thought suppose my terminal theme is Gruvbox but when I read and log file through moar then it uses Dracula color rendering so thought color style is the option to do so..BAT do this for me.

ciscohack commented 1 year ago

Like this example the terminal theme is Solarize but BAT theme is gruvbox and rendering is also like gruvbox

image

now here same file in moar

image
walles commented 1 year ago

What command line did you use to get this?

That's a shell script, and if it's named whatever.sh then moar should highlight it.

ciscohack commented 1 year ago

Ran command moar .exports and bat .exports in kitty terminal . As I said I already tested all combo before raising ticket moar is not working as I received whereas BAT is working fine

walles commented 1 year ago

I experimented a bit and it seems like bat looks at the contents of the file to identify its MIME type, whereas moar just looks at the file name.

Sort of related to #134.

It might be possible to have moar use DetectContentType() as a fallback to determine the MIME type if the file name based detection fails.

This would likely fix the .exports highlighting, but it would not do anything for the asa.log highlighting that you mentioned above: https://github.com/walles/moar/issues/159#issuecomment-1741984095

ciscohack commented 1 year ago

hmm okay thanks John

walles commented 1 year ago

But DetectContentType seems pretty limited: https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/net/http/sniff.go;l=65-195

This one seems broader, but doesn't detect shell scripts: https://github.com/gabriel-vasile/mimetype

Same for this one, doesn't detect shell scripts: https://github.com/h2non/filetype

This one has native dependencies, making it impractical: https://github.com/rakyll/magicmime

Other suggestions welcome, none of the above are usable for this out of the box unfortunately.

walles commented 1 year ago

This one seems nice, but requires the user to have Tensorflow installed, which I assume most people don't: https://github.com/robherley/guesslang-go

ciscohack commented 1 year ago

@walles Thanks a lot my friend for all your support and time on this. Yes, many and even I don't like 10 other dependencies installed to run 1 software. That's ok you can leave I use BAT for such needs as

walles commented 1 year ago

Yet another candidate that doesn't recognize shell scripts: https://github.com/zRedShift/mimemagic

ciscohack commented 1 year ago

@walles it's not about shell script i feel scripts anyway moar is able to recognize

walles commented 1 year ago

What text file formats would be important for you?

ciscohack commented 1 year ago

txt and log these are 2 most common type

walles commented 1 year ago

Neither of those have any highlighting, so even if they were detected correctly they wouldn't receive any highlighting anyway.

ciscohack commented 1 year ago

@walles there is highlight for log in BAT but point is not about highlight..seems you not getting the request fully I said suppose my terminal theme is solarize and want my moar to render any log in color of gruvbox .. I gave you the screenshot above for very same comparision

walles commented 1 year ago

Do you mean that the text of the log should have some certain color based on the theme (gruvbox)?

ciscohack commented 1 year ago

@walles just noticed the screenshot and understands the requirement. below SS my terminal theme is Solarize dark and when I ran bat the color of text is a little yellowish and some numeric and hex values were highlighted

Whereas when I ran same thing in moar in second SS. You will see it used the Solarize theme colour style only for text though I have color style gruvbox chosen in moar

With gruvbox color style in BAT:--

image

With gruvbox color style in moar:--

image

Ideally when I choose the color style gruvbox in moar then color of text should be little yellowish as in first screenshot. Now I hope you understand the requirement

walles commented 1 year ago

After cbbdaf632b322eadd915ba9659f873f8213d64f1, just released with v1.18.1, this should now work on 256 color terminals as well.

ciscohack commented 1 year ago

@walles you said that 1.8.0 will have syntax highlights like bat to some extent for log/text files like in bat screenshot above but I don't see it ..

walles commented 1 year ago

Try v1.18.1.

ciscohack commented 1 year ago

ok thanks, waiting for the release update to be available

ciscohack commented 1 year ago

@walles just upgraded to 1.18.1 but the result is not what asked second I don't know what changes you did but anyway thank you so much for all your hard work

walles commented 1 year ago

If you want real highlighting of .log files you have to request it here: https://github.com/alecthomas/chroma/issues

After it's implemented there then moar can be upgraded.

Here's what moar --style=gruvbox /etc/services does with moar 1.18.1. Notice how the color of text is a little yellowish for this unknown-format file. Was that not what you asked for in https://github.com/walles/moar/issues/159#issuecomment-1744124203?

Skärmavbild 2023-10-14 kl  18 47 40
ciscohack commented 1 year ago

@walles now try Dracula and cappuccino-macchiato style and see what moar color is rendering.. you can see the below SS output moar is producing totally different style

moar --style=catppuccin-macchiato new\ 219.txt

image
walles commented 1 year ago

I'll need to bump Chroma to a newer version for this, the catppuccin themes were updated in July: https://github.com/alecthomas/chroma/pull/797

ciscohack commented 1 year ago

@walles Thanks, In fact for another style.. the result outcome is not that good I means only this area Moar lack a functionality compare to BAT else moar has unmatched and the best tool

walles commented 1 year ago

Is this closer to what you'd expect from --style=catppuccin-macchiato?

Skärmavbild 2023-10-15 kl  07 53 00
ciscohack commented 1 year ago

Is this closer to what you'd expect from --style=catppuccin-macchiato?

Skärmavbild 2023-10-15 kl 07 53 00

yes color point of view it's now as per your SS seems matching but there is no highlight at least for some keyword like IP/Port HEX value etc. as bat is doing

walles commented 1 year ago

If you want log file highlighting you have to request it here:

https://github.com/alecthomas/chroma/issues

ciscohack commented 1 year ago

If you want log file highlighting you have to request it here:

https://github.com/alecthomas/chroma/issues

The request is already raised but I don't know whether they will do it or not.

https://github.com/alecthomas/chroma/issues/871

ciscohack commented 1 year ago

@walles is this --style=catppuccin-macchiato? issue resolved as I am still having the problem and this style showing red color

walles commented 1 year ago

Just released moar v1.18.2 with that fix in it.

ciscohack commented 1 year ago

Just released moar v1.18.2 with that fix in it.

ok Thanks!