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

Add a more terminal-friendly command layout #1187

Closed
stdedos opened this issue Sep 14, 2020 · 9 comments
Closed

Add a more terminal-friendly command layout #1187

stdedos opened this issue Sep 14, 2020 · 9 comments
Labels
feature-request New feature or request

Comments

@stdedos
Copy link

stdedos commented Sep 14, 2020

I have been trying to use bat as a drop-in replacement to cat, and routinely I fall into various small problems.
Today, I want to talk about line numbers.

Sometimes I want, while seeing a file, to copy a portion of it.
At the same time, I find line numbers useful.

The above give me an impass:

  • Copying part of a file to some other place, with the leading line numbers is usually not okay (except if I copy to an intermediate Sublime /w multicursors)
  • Temporarily having no line numbers is not "that straightforward":
    • I don't remember the flag for it
    • no tab-completion for bash
    • Will either incur a re-execution, or
    • using less' line numbers will add a +3 offset (separator, filename, separator)
    • bat cannot, by itself, on-demand add/remove numbers during interaction (as usually it's job is most likely already done before I see anything)

With all the aforementioned, I propose a new layout theme, that starts with the file, and leads with whatever else (separator, filename, separator). With that, using less' -N becomes a trivial solution to this issue.

Or implement less in bat 😜

@stdedos stdedos added the feature-request New feature or request label Sep 14, 2020
@sharkdp
Copy link
Owner

sharkdp commented Sep 14, 2020

Thank you for the detailed feedback.

Sometimes I want, while seeing a file, to copy a portion of it.
At the same time, I find line numbers useful.

That hat been discussed multiple times. See e.g. #549, #296, #467, #1177, #939

With all the aforementioned, I propose a new layout theme, that starts with the file, and leads with whatever else (separator, filename, separator).

I don't understand?

Or implement less in bat 😜

See #1053

@stdedos
Copy link
Author

stdedos commented Sep 14, 2020

Sometimes I want, while seeing a file, to copy a portion of it.
At the same time, I find line numbers useful.

That hat been discussed multiple times. See e.g. #549, #296, #467, #1177, #939

Oh, I missed the "toggle" keyword 😕

With all the aforementioned, I propose a new layout theme, that starts with the file, and leads with whatever else (separator, filename, separator).

I don't understand?

Basically the reverse of this, without the sidebar
img

# Markdown example

...

----
File:
----

(I'm sorry I don't have access to a textual bat output right now)

It looks weird, prohibits git-markers, but it would be a minimal solution to this (not considering the already-mentioned tickets ofc)

@sharkdp
Copy link
Owner

sharkdp commented Sep 14, 2020

You can already do this by adding

--style=header,grid,snip

to your config file.

@stdedos
Copy link
Author

stdedos commented Sep 15, 2020

I meant:

bat$ (master u=) bat examples/cat.rs 
/// A very simple colorized `cat` clone, using `bat` as a library.
/// See `src/bin/bat` for the full `bat` application.
use bat::PrettyPrinter;

fn main() {
    PrettyPrinter::new()
        .header(true)
        .grid(true)
        .line_numbers(true)
        .input_files(std::env::args_os().skip(1))
        .print()
        .unwrap();
}
────────────────────────────────────────────────────────────────────
 File: examples/cat.rs
────────────────────────────────────────────────────────────────────
bat$ (master u=)

which less -N can number accurately

@sharkdp
Copy link
Owner

sharkdp commented Sep 20, 2020

If it's going to work for a single file only, why not leave out the header part completely?

@stdedos
Copy link
Author

stdedos commented Sep 21, 2020

True dat. I didn't think of it.

@sharkdp
Copy link
Owner

sharkdp commented Oct 1, 2020

I take this to mean that this can be closed?

@sharkdp sharkdp closed this as completed Oct 1, 2020
@stdedos
Copy link
Author

stdedos commented Oct 1, 2020

Well, I don't know what would help more, given that bundled pager is already in planning and since my idea of header-becoming-footer is not getting traction...

I am now using the new configuration, and I feel that "the bat I know" is no longer there.
Maybe I need to add a bat alias with the default configuration, and let non-aliased innovations take the "only coloring" execution path.

@sharkdp
Copy link
Owner

sharkdp commented Oct 3, 2020

Hm. I'm not really sure how we could help with that?

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

No branches or pull requests

2 participants