sharkdp / bat

A cat(1) clone with wings.
Apache License 2.0
49.65k stars 1.25k forks source link

Can bat mimic behavior of less -S #1188

Closed figgis closed 4 years ago

figgis commented 4 years ago

Hi,

I have log-files containing huge arrays of integers and wrapping makes it very hard to see changes across lines. less -S works great here, but I can't seem to get bat to chop long lines.

echo {1..100} | bat --style plain --wrap=never
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

I have tried every wrap-mode there is together with --terminal-width but I can't chop off long lines. No mater what I do I get a wrap.

Compare with less:

$ echo {1..100} | less -S -X
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

Have I misunderstood --wrap never or isn't this feature available in bat?

Using

$ bat --version
bat 0.15.4
sharkdp commented 4 years ago

Have I misunderstood --wrap never or isn't this feature available in bat?

--wrap never will disable wrapping in bats output, but you will still get wrapping in the pager. You can use

--wrap=never
--pager="less -FRS"

in bats config file (or on the command line) to make this work:

echo {1..100} | bat --wrap=never --pager="less -FRS"

Unfortunately, it also seems to disable the -F feature ("quit if one screen").

figgis commented 4 years ago

I forgot to say thanks. Thanks! I have wrappet bat in a alias to do this.

Riveascore commented 2 years ago

@sharkdp https://github.com/sharkdp/bat/issues/1188#issuecomment-693622221

❤️❤️❤️

I had stopped using bat as my main pager for a while, because less -S is so useful for postgres horizontal scrolling.
I'm so thankful for this info because I can go back to using bat for everything.