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

Wrapping does not work when piping #758

Closed
desbma opened this issue Nov 27, 2019 · 9 comments
Closed

Wrapping does not work when piping #758

desbma opened this issue Nov 27, 2019 · 9 comments
Labels
feature-request New feature or request good first issue Good for newcomers

Comments

@desbma
Copy link

desbma commented Nov 27, 2019

Line wrapping seems to be disabled when piping to another process, even when forced with --wrap=character.

$ echo 123456789abcd > /tmp/file
$ bat --style plain --terminal-width 10 --wrap=character /tmp/file
123456789a
bcd
$ bat --style plain --terminal-width 10 --wrap=character /tmp/file | command cat
123456789abcd
@tzhouhc
Copy link

tzhouhc commented Dec 20, 2019

This line checks and gives up on wrapping if the bat call is not interactive, but if we are providing an absolute width explicitly it should be fine...?

Allowing this would be immensely helpful with fzf preview integration.

@sharkdp
Copy link
Owner

sharkdp commented Dec 20, 2019

but if we are providing an absolute width explicitly it should be fine...?

Yes, I think so. Sounds like an easy fix 👍

@sharkdp sharkdp added feature-request New feature or request good first issue Good for newcomers labels Dec 20, 2019
@fusillicode
Copy link
Contributor

fusillicode commented Dec 21, 2019

Hi 😄

me and @allevo are trying to tackle this issue and we actually pulled out this preliminary PR.

To solve the issue however it seems that we must extend the SimplePrinter to actually consider the wrapping. Does it sounds right? 🤔

If yes how should we proceed with a new PR that address the actual SimplePrinter implementation? 🤔

@fusillicode
Copy link
Contributor

Just a quick update, we managed to extend the SimplePrinter 😄

Here's the separated PR.

Let us know how we can proceed 😄

@sharkdp
Copy link
Owner

sharkdp commented Dec 22, 2019

Maybe I was too fast with merging #785. Wrapping works just fine if we disable interactive mode by using --color=always or --decorations=always, right?

# color and decorations:
bat --terminal-width 50 --wrap=character --color=always src/assets.rs |# color only
bat --terminal-width 50 --wrap=character --color=always --plain src/assets.rs |# no color
bat --terminal-width 50 --wrap=character --decorations=always src/assets.rs |# no color, no decorations
bat --terminal-width 50 --wrap=character --decorations=always --plain src/assets.rs |

@desbma
Copy link
Author

desbma commented Dec 22, 2019

Wrapping works just fine if we disable interactive mode by using --color=always or --decorations=always, right?

No, it does not:

$ echo 1234567890ABCD | bat --plain --color=always --wrap character --terminal-width 10 | command cat
1234567890ABCD

@sharkdp
Copy link
Owner

sharkdp commented Dec 22, 2019

Ah, ok. So #785 was indeed necessary to fix this. It does work on master:

❯ echo 1234567890ABCD | bat --plain --color=always --wrap character --terminal-width 10 | command cat
1234567890
ABCD

@sharkdp
Copy link
Owner

sharkdp commented Mar 6, 2020

It looks like this can be closed.

@sharkdp sharkdp closed this as completed Mar 6, 2020
@sharkdp
Copy link
Owner

sharkdp commented Mar 22, 2020

This has been fixed in bat 0.13.

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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants