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

Terminal width incorrect when using less -J #81

Closed
wren opened this issue Sep 21, 2022 · 1 comment
Closed

Terminal width incorrect when using less -J #81

wren opened this issue Sep 21, 2022 · 1 comment
Labels
batpipe Related to the batpipe script. enhancement New feature or request

Comments

@wren
Copy link

wren commented Sep 21, 2022

Hi! I firstly wanted to thank you for this very useful project. I use it all the time and it's really streamlined my workflow in a lot of ways.

Problem

I also wanted to report an issue when using the -J option in less. This option "Displays a status column at the left edge of the screen." I find this useful when searching in a document since it adds a * icon to any line with a search result. The problem that I'm having is that this makes the terminal slightly wider than bat expects, and leads to every document that is opened to be just a few characters too wide for the screen.

This issue was brought up to bat a while back (sharkdp/bat#376), which resulted in the addition of the --terminal-width option. This works great with bat by doing something like bat --terminal-width=-3. The problem when using batpipe, though, is that the --terminal-width option is overridden and not passed on to bat (see here).

I'm not sure why this behavior exists in batpipe, but I assume there's a reason. I was wondering if this could be updated to account for the --terminal-width option somehow and pass it on to bat when present.

Proposed Solution

I was thinking that an environment variable (e.g. BATPIPE_TERM_WIDTH or whatever) could be introduced to adjust the term width. When present, it would adjust the number passed to --terminal-width.

If there's a different preferred approach, though, just let me know. Either way, I'm happy to send a PR to fix this once I hear if this fix would be welcome.

Thank you!

wren added a commit to wren/dotfiles that referenced this issue Sep 21, 2022
This breaks with batpipe at the moment (the screen is always a few
characters too wide). Disabling this until the issue below is resolved
in batpipe.

eth-p/bat-extras#81
@eth-p
Copy link
Owner

eth-p commented Mar 21, 2023

Thanks for the suggestion! I originally created this project for my own workflow-related reasons, and it's always nice to hear that it's helped others too :)

I implemented your suggestion in 4e2bd77. I tested it locally with less -J and it seemed to work as intended, but please let me know if you encounter any issues with it. A new release should be coming soon-ish, after I've read through all the issues and PRs that I've been behind on.

@eth-p eth-p added enhancement New feature or request batpipe Related to the batpipe script. pending closure All requested changes/fixes have been made. and removed pending closure All requested changes/fixes have been made. labels Mar 21, 2023
@eth-p eth-p closed this as completed Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batpipe Related to the batpipe script. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants