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

Feature Request: Display binary files with hexyl #619

Closed
casey opened this issue Jul 31, 2019 · 10 comments
Closed

Feature Request: Display binary files with hexyl #619

casey opened this issue Jul 31, 2019 · 10 comments
Labels
feature-request New feature or request

Comments

@casey
Copy link

casey commented Jul 31, 2019

It would be super cool to display binary files with hexyl!

@stefanvanburen
Copy link

Maybe you meant to put this on the hexyl issue tracker? :)

@casey
Copy link
Author

casey commented Jul 31, 2019

I meant that bat, when it previews a binary file, should display the contents with hexyl. Should that go on the hexyl issue tracker?

@stefanvanburen
Copy link

ah, that makes more sense, sorry - I'm assuming you'd want more than bat --pager=hexyl?

@casey
Copy link
Author

casey commented Jul 31, 2019

No worries! I think that bat --pager=hexyl will pipe all of bat's output through hexyl, instead of just the file contents. Mainly I'd like bat to display binary files somehow, so I don't need to think about if I need bat or hexyl beforehand.

@stefanvanburen
Copy link

that would be pretty cool - also, cheers for the just project, I've always been super tempted to use it over make haha

@casey
Copy link
Author

casey commented Jul 31, 2019

Thank you! If there's ever a feature you need that make has and just doesn't, please feel free to open an issue ^_^

@sharkdp
Copy link
Owner

sharkdp commented Aug 1, 2019

Thank you for the feedback. That sounds like an interesting idea.

It might make sense to not hard-code this to hexyl, but to introduce BAT_BINARY_VIEWER and to provide a (prioritized) internal list of hex viewers which would be tried in sequence, in case BAT_BINARY_VIEWER is not set. Obviously, hexyl would be on the top of this list 😄 😄

Also, we would need to restrict this to interactive mode (i.e. only call the external program if the output goes to an interactive terminal).

Another thing to think about is whether we should only show a preview of the file (e.g. the first 512 bytes). I could imagine that a lot of bat some-binary-file calls are actually accidents (when using shell globs, for example).

@sharkdp sharkdp added the feature-request New feature or request label Aug 1, 2019
@casey
Copy link
Author

casey commented Aug 3, 2019

It might make sense to not hard-code this to hexyl, but to introduce BAT_BINARY_VIEWER and to provide a (prioritized) internal list of hex viewers which would be tried in sequence, in case BAT_BINARY_VIEWER is not set. Obviously, hexyl would be on the top of this list 😄 😄

If it's parameterized, the --color option should probably also be passed through, although that might be tricky, since not all hex viewers are likely to support a --color option with the same semantics as bat and hexyl.

Another thing to think about is whether we should only show a preview of the file (e.g. the first 512 bytes). I could imagine that a lot of bat some-binary-file calls are actually accidents (when using shell globs, for example).

Is the concern that it would be slow to read the entire file? I suppose this would matter if the user passes --paging=never and hexyl tries to display a giant file.

@sharkdp
Copy link
Owner

sharkdp commented Sep 2, 2019

Not quite the same, but I recently added support for viewing binary files via bat -A.

@sharkdp
Copy link
Owner

sharkdp commented Oct 29, 2019

With the enhanced -A option in place, I'm not sure if we need this. But we could probably advertise it in the output, instead of just showing

File: whatever   <BINARY>

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

No branches or pull requests

3 participants