You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's two different ways of specifying that decorations should not be displayed when the output is piped, and they both independently suppress the decorations. In particular, this is --style=auto and --decorations=auto. Both are documented as being the default (though it appears that --style=auto is not in fact the default, see #1742, possibly because of this issue). This is confusing as it means bat --style=full foo | cat omits decorations, and bat --style=auto --decorations=always foo | cat also omits decorations (this is more confusing if --style=auto is set in config, and so bat -f foo | cat will still omit decorations).
This is also frustrating if you want to turn off the auto style but aren't sure if the inherited style is actually auto or not. For example, bat --style=full -f foo | cat will ensure all decorations are on, but if my config includes --number then this will override that and turn on all decorations. Which is to say, there's no way to ensure decorations are visible without either knowing the current style or risking changing the style.
What did you expect to happen instead?
At the very least, bat needs to stop claiming --style=auto is the default, and it really should make it clear what the relationship is between --style and --decorations, and that saying --style=auto means --decorations=always isn't sufficient to print decorations when piped. This doesn't solve the problem of forcing auto decorations on though.
Also it looks like bat can actually mark some style components as auto and others as always, by writing this like --style=auto,numbers, such that bat --style=auto,numbers -f foo | cat will print numbers but printing to the terminal will display all decorations. This is undocumented, but is an argument against changing the actual meaning of --style=auto.
But I think we can also do something intelligent here by providing per-style-component control over auto behavior. We could allow for writing something like --style=numbers:auto,header (and then --style=auto just becomes the same thing as --style=full:auto), or perhaps a prefix sigil like --style=*numbers,header (or maybe some other sigil that doesn't need escaping from the shell). This doesn't solve the problem of "both style and decorations have independent auto toggles that stack", but it may make the fact that they stack a bit easier to understand (i.e. "--decorations=auto controls decorations when piping normally, but you can flag independent style components as auto if you want them to still be omitted when piping with -f").
Also I think we should find some way to make -ff force all auto-flagged styles as visible when piped. This way I can say -ff to means "no really, please pipe exactly the output I'd see at a terminal", such as if I want to capture the output to a file. Perhaps this could be done by adding another value --decorations=forced, and then -ff can add the --decorations=forced flag just like how -pp adds -pager=never.
How did you install bat?
Nix
bat version and environment
Software version
bat 0.18.0
Operating system
Darwin 20.5.0
The text was updated successfully, but these errors were encountered:
Describe the bug you encountered:
There's two different ways of specifying that decorations should not be displayed when the output is piped, and they both independently suppress the decorations. In particular, this is
--style=auto
and--decorations=auto
. Both are documented as being the default (though it appears that--style=auto
is not in fact the default, see #1742, possibly because of this issue). This is confusing as it meansbat --style=full foo | cat
omits decorations, andbat --style=auto --decorations=always foo | cat
also omits decorations (this is more confusing if--style=auto
is set in config, and sobat -f foo | cat
will still omit decorations).This is also frustrating if you want to turn off the auto style but aren't sure if the inherited style is actually auto or not. For example,
bat --style=full -f foo | cat
will ensure all decorations are on, but if my config includes--number
then this will override that and turn on all decorations. Which is to say, there's no way to ensure decorations are visible without either knowing the current style or risking changing the style.What did you expect to happen instead?
At the very least,
bat
needs to stop claiming--style=auto
is the default, and it really should make it clear what the relationship is between--style
and--decorations
, and that saying--style=auto
means--decorations=always
isn't sufficient to print decorations when piped. This doesn't solve the problem of forcing auto decorations on though.Also it looks like
bat
can actually mark some style components as auto and others as always, by writing this like--style=auto,numbers
, such thatbat --style=auto,numbers -f foo | cat
will print numbers but printing to the terminal will display all decorations. This is undocumented, but is an argument against changing the actual meaning of--style=auto
.But I think we can also do something intelligent here by providing per-style-component control over auto behavior. We could allow for writing something like
--style=numbers:auto,header
(and then--style=auto
just becomes the same thing as--style=full:auto
), or perhaps a prefix sigil like--style=*numbers,header
(or maybe some other sigil that doesn't need escaping from the shell). This doesn't solve the problem of "both style and decorations have independent auto toggles that stack", but it may make the fact that they stack a bit easier to understand (i.e. "--decorations=auto
controls decorations when piping normally, but you can flag independent style components as auto if you want them to still be omitted when piping with-f
").Also I think we should find some way to make
-ff
force all auto-flagged styles as visible when piped. This way I can say-ff
to means "no really, please pipe exactly the output I'd see at a terminal", such as if I want to capture the output to a file. Perhaps this could be done by adding another value--decorations=forced
, and then-ff
can add the--decorations=forced
flag just like how-pp
adds-pager=never
.How did you install
bat
?Nix
bat version and environment
Software version
bat 0.18.0
Operating system
Darwin 20.5.0
The text was updated successfully, but these errors were encountered: