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

moar style switch seems broken and not working #159

Closed
ciscohack opened this issue Sep 30, 2023 · 42 comments
Closed

moar style switch seems broken and not working #159

ciscohack opened this issue Sep 30, 2023 · 42 comments

Comments

@ciscohack
Copy link

ciscohack commented Sep 30, 2023

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

ciscohack commented Sep 30, 2023

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

walles commented Sep 30, 2023

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

mtvrsh commented Sep 30, 2023

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

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

walles commented Oct 1, 2023

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

  • moar --style=gruvbox moar.go
  • moar moar.go
  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
Copy link
Author

here is the output of commands

moar --style=igor asa.log
image

moar --style=gruvbox asa.log
image

@walles
Copy link
Owner

walles commented Oct 1, 2023

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

Ref: #128 (comment)

@ciscohack
Copy link
Author

ciscohack commented Oct 1, 2023

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

walles commented Oct 1, 2023

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

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

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

walles commented Oct 1, 2023

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

ciscohack commented Oct 1, 2023

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

walles commented Oct 1, 2023

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: #159 (comment)

@ciscohack
Copy link
Author

hmm okay thanks John

@walles
Copy link
Owner

walles commented Oct 1, 2023

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

walles commented Oct 2, 2023

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

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

walles commented Oct 2, 2023

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

@ciscohack
Copy link
Author

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

@walles
Copy link
Owner

walles commented Oct 2, 2023

What text file formats would be important for you?

@ciscohack
Copy link
Author

txt and log these are 2 most common type

@walles
Copy link
Owner

walles commented Oct 2, 2023

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

@ciscohack
Copy link
Author

ciscohack commented Oct 2, 2023

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

walles commented Oct 2, 2023

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

@ciscohack
Copy link
Author

@walles just noticed the screenshot and understands the requirement. below SS my terminal theme is Solarize dark and when I ran bat <file_name.log> 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 walles closed this as completed in 251513e Oct 6, 2023
@walles
Copy link
Owner

walles commented Oct 14, 2023

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

@ciscohack
Copy link
Author

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

walles commented Oct 14, 2023

Try v1.18.1.

@ciscohack
Copy link
Author

ciscohack commented Oct 14, 2023

ok thanks, waiting for the release update to be available

@ciscohack
Copy link
Author

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

walles commented Oct 14, 2023

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 #159 (comment)?

Skärmavbild 2023-10-14 kl  18 47 40

@ciscohack
Copy link
Author

ciscohack commented Oct 14, 2023

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

walles commented Oct 14, 2023

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

walles added a commit that referenced this issue Oct 14, 2023
@ciscohack
Copy link
Author

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

walles commented Oct 15, 2023

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

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

@ciscohack
Copy link
Author

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

walles commented Oct 15, 2023

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

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

@ciscohack
Copy link
Author

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.

alecthomas/chroma#871

@ciscohack
Copy link
Author

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

@walles
Copy link
Owner

walles commented Oct 17, 2023

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

@ciscohack
Copy link
Author

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

ok Thanks!

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

3 participants