Skip to content

FR: use different style when showing multiple files, one file, (maybe) piped input #3425

@ilyagr

Description

@ilyagr

Request

Currently, there is a --style=auto option for using the "full" style when showing files and the "plain" style when showing piped input.

Instead, I would like to use my preferred style (--style header,grid) when showing multiple files, and to use the plain style when showing piped input or one file from the command line.

Possible design

The most obvious (to me) approach would be to have three new options: --style-single-file, --style-stdin, and --style-multiple-files, which would each override --style in the relevant situation.

A corner case is what to do for

echo qq | bat -

I'd use --style-stdin here, it's more consistent with bat and bat - behaving the same. OTOH, --style-single-file would also be OK and slightly more consistent with the next corner case I describe below.

Another corner case is

echo qq | bat - filename

My preference would be to use --style-multiple-files for both STDIN and the filename. Using different styles on different files printed together would look weird.

Alternative possibilities

We could also implement slightly less (for now) and have just two options, --style-multiple-files and --style-single-file, where the latter is applied to piped input as well (except for the echo qq | bat - filename case). I think I'd personally be just as happy with this as I'd be with implementing three options. This would not allow expressing --style=auto with the new options.

My original idea was to ask merely for using my preferred style on files and using the plain style when showing piped input. That would also be an improvement, though I then realized what I really care about is whether multiple files are shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions