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

Language formatting #1592

Closed
gomeology opened this issue Mar 19, 2021 · 3 comments
Closed

Language formatting #1592

gomeology opened this issue Mar 19, 2021 · 3 comments
Labels
feature-request New feature or request

Comments

@gomeology
Copy link

gomeology commented Mar 19, 2021

Is it possible to have the output formatted in a more readable format. example in the images below
unformatted
formatted

@gomeology gomeology added the feature-request New feature or request label Mar 19, 2021
@keith-hall
Copy link
Collaborator

Thanks for the request. I personally think reformatting is out of scope for bat, partially because its billed as a cat replacement with syntax highlighting and other optional features. Thus it typically shows files exactly as they appear on disk, just with color and line numbers etc.

I don't know of any way to easily pretty print any type of file, (which would thus be another thing to maintain) but for your concrete use case you could use jq and pipe the output into bat. You could also make a shell alias if its something you want to do often / by default :)

@Enselic
Copy link
Collaborator

Enselic commented Mar 20, 2021

Just wanted to chime in with a JSON formatting tip. I personally prefer python3 -m json.tool over tools such as e.g. jq since the former is usually installed by default on most systems. Combined with bat it would look like this (with colors in a real terminal, of course):

% echo '{"format":"me", "please": true}' | python3 -m json.tool | bat -l json
───────┬────────────────────────────────────────────────────
       │ STDIN
───────┼────────────────────────────────────────────────────
   1   │ {
   2   │     "format": "me",
   3   │     "please": true
   4   │ }
───────┴────────────────────────────────────────────────────

@sharkdp
Copy link
Owner

sharkdp commented May 12, 2021

Please check out prettybat in https://github.com/eth-p/bat-extras

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

4 participants