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

cat -s clone #762

Closed
syu-id opened this issue Dec 5, 2019 · 7 comments · Fixed by #2665
Closed

cat -s clone #762

syu-id opened this issue Dec 5, 2019 · 7 comments · Fixed by #2665
Labels
feature-request New feature or request

Comments

@syu-id
Copy link

syu-id commented Dec 5, 2019

The -s / --squeeze-blank option of cat can "squeeze" consecutive blank lines into one.

     1  hello
     2
     3
     4  world
     5
     6
     7
     8  世界

With cat -s, the above text will become:

     1  hello
     2
     3  world
     4
     5  世界

It would be convenient if bat provides the same functionality.

@eth-p
Copy link
Collaborator

eth-p commented Dec 5, 2019

While I can see that as a convenient option, it also goes against the philosophy of "do one thing, and do it well."

Using an external command and a pipe would probably be more flexible and configurable. If you care about preserving the line numbers but not displaying the consecutive blank lines though, we would have to implement that inside bat like you suggested.

@eth-p eth-p added feature-request New feature or request help wanted Extra attention is needed question Further information is requested and removed help wanted Extra attention is needed labels Dec 5, 2019
@syu-id
Copy link
Author

syu-id commented Dec 5, 2019

I'm interested in simply removing consecutive blank lines, like what cat -s does.
I agree that one can remove such lines rather easily with some external command e.g. the following awk code:

.... | awk '{ /^\s*$/?b++:b=0; if (b<=1) print }' | bat

But as you can see this adds a lot of text (as well as some cognitive load) compared to -s. The -s option is pretty handy when the input contains many meaningless empty lines and the user wants to have a quick compact preview. While this is a trivial functionality, it could also make bat a more complete replacement of (GNU) cat.

@sharkdp
Copy link
Owner

sharkdp commented Dec 22, 2019

Since #766 has been merged, the following would also work:

bat --plain --color=always … | cat -s

@sharkdp
Copy link
Owner

sharkdp commented Feb 28, 2020

Closing this for now, as there is no plan to implement this and there is a reasonable alternative.

@sharkdp sharkdp closed this as completed Feb 28, 2020
@danielb2
Copy link

danielb2 commented Dec 16, 2020

I would also like to see this implemented. It falls under "do one thing and do one thing well" if you want to cat a file for inspection (what else is cat for?) that has a ton of newlines. Such newlines can push content that I want to see off the screen requiring scrolling to view the contents of the file.

Adding this feature makes it do the job BETTER. The only reasonable alternative now is to fall back on cat -s. I was hoping bat would be a full replacement.

@sharkdp
Copy link
Owner

sharkdp commented Jan 8, 2021

see #1441

@sharkdp sharkdp removed the question Further information is requested label Jan 9, 2021
@nerun
Copy link

nerun commented Jul 30, 2023

I do need this option -s, --squeeze-blank, awaiting for this.

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

Successfully merging a pull request may close this issue.

5 participants