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 defining a filter/preprocessor #2289

Open
xeruf opened this issue Aug 30, 2022 · 2 comments
Open

Allow defining a filter/preprocessor #2289

xeruf opened this issue Aug 30, 2022 · 2 comments
Labels
feature-request New feature or request

Comments

@xeruf
Copy link
Contributor

xeruf commented Aug 30, 2022

i.e. a command that processes the input before it is displayed by bat.

I often want bat's nice filename display, ruler and line number, but can't give it the file directly.
For example in #2024 I wanted to use cut, now I am building something with python -m json.tool to format json before displaying it in bat with syntax highlighting. By adding the ability to process the input, one could use both nicely :)

So rather than:

cat "$@" | python -m json.tool | bat --language json --style numbers

I could use something like:

bat --language json --style header,rule,numbers --process 'python -m json.tool' "$@"

This way I can distinguish the files.

I guess the processor should be invoked line-based, or there could be a separate --process-lines option.

@xeruf xeruf added the feature-request New feature or request label Aug 30, 2022
@keith-hall
Copy link
Collaborator

the proof of concept of bat plugins would likely fit this use case: #2203

@xeruf
Copy link
Contributor Author

xeruf commented Nov 18, 2023

I just encountered a good use-case again, where I would like to reproduce git log -p in fossil, viewing each commit like a separate file in bat ^^

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

2 participants