-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Intelligent support for LESSOPEN
and LESSCLOSE
#1739
Comments
Another preprocessor use-case I just found: teaching Basically, the preprocessor should act something like At a first pass, the syntax could be something like I could then add something like the following to my config: QuestionFor preprocessors that provide colored output, should bat strip the color codes when piping (using the same rules as its own built-in syntax coloring)? Should we distinguish between preprocessors that only run interactively vs preprocessors that always run? I'm thinking here in the context of using Do we want to define any env vars when executing the preprocessor, so users can write preprocessor scripts that act intelligently? For example, informing the preprocessor about whether bat would otherwise show colors or decorations. |
Possibly related? #1597 |
Let's turn this into a generic issue for some kind of support for |
plutil -p
LESSOPEN
and LESSCLOSE
My concern with Given that, my initial thoughts are:
The ability to configure this per file pattern is something I really want. I tend not to use |
@lilyball The |
I noticed this issue linked in the patch notes, should this still be open? |
I think we can close, thanks for the reminder! |
Probably the new functionality should be documented under "Integration with other tools" ? https://github.com/sharkdp/bat?tab=readme-ov-file#integration-with-other-tools |
macOS has 3 different plist formats, two of them textual (NeXTStep and XML) and one binary. The textual plists are human-readable already, but the binary one isn't, and trying to run
bat
on it just warns me that it's a binary file.What I'd really like is a way to configure
bat
to run plists throughplutil -p
to get a human-readable textual output. It could note that the file has been preprocessed this way in the header. And there should be an easy way to disable this (such as a flag that says "disable file preprocessors"). This would be similar toLESSOPEN
(which has the flag-L
to disable it), except defined on a per–file extension basis rather than being a global option that requires the script to decide what to do (this waybat
can know and display whether the file has been preprocessed).Optionally, this
plutil -p
preprocessing could be done only for binary files, this way runningbat
on an XML plist would show the XML. I'm not sure whether this is a good idea. This approach could then mean the flag to disable preprocessing could look like--preprocess=always|binary|never
, though I suppose having that as a global option is unfortunate if I want to only preprocess binary plists but always preprocess some other file type. I'm not aware of any precedent for setting per-language options though (just for mapping file globs to syntax names). Perhaps the syntax to define a preprocessor could allow for selecting whether it should only apply to binary files. Or maybe the preprocessor itself should just be a script that makes that call, though in this casebat
doesn't know whether the file has been modified (which seems like a very useful thing to know for displaying in the header). Or maybe this is just overcomplicating it and a preprocessor should just be defined for a file pattern and I can use the appropriate flag to disable it if I want to see the original file.Side note: if
bat
ever becomes a pager in its own right instead of relying onless
it could then have an interactive option to toggle the preprocessor off or on.Also, while I've been talking about plists, I could imagine this ability being useful for e.g. displaying metadata about images or videos, or displaying some sort of summary of sqlite files, or other similar preprocessors.
Alternatives
While a generic preprocessor feature seems useful, as an alternative
bat
could simply bake in knowledge of plists on macOS only (along with a macOS-only flag to disable plist transformations). It could either still just run them throughplutil -p
, or it could call into CoreFoundation to parse the plist directly, though I'm not aware offhand of any way to get theplutil -p
output format that way without reimplementing it by hand.The text was updated successfully, but these errors were encountered: