bat icon indicating copy to clipboard operation
bat copied to clipboard

Highlighted search for manpager

Open paulwyszynski opened this issue 10 months ago • 3 comments

Hi!

Is it possible to add color highlighting for the current selected search item? When searching for keywords with /, all items are highlighted and when navigating with n and N back and forth to the next/previous item you can't actually see where the cursor is at the moment.

See attached file man magick (taken from imagemagick man page)

Screenshot 2025-01-13 at 23 54 01

paulwyszynski avatar Jan 13 '25 22:01 paulwyszynski

I'm not a less expert by any means, but it seems like it simply doesn't support this. The closest related switch I can see is this one: https://github.com/gwsw/less/blob/master/less.hlp#L150

Maybe once https://github.com/sharkdp/bat/issues/1540 is done, there will be more options available here :)

keith-hall avatar Jan 14 '25 18:01 keith-hall

All right. Thanks 🙂

paulwyszynski avatar Jan 14 '25 22:01 paulwyszynski

I'm using vim +Man! -c "set signcolumn=no" -c "set cmdheight=1" -c "set laststatus=1" as my MANPAGER, it automatically highlights search in man pagers.

But I notice that I got no search highlight when I use bat or less after pipe, after I add the following part in my fish shell config, search highlight works for both less and bat, it affects bat as well since (I guess) in man bat, it got a line "bat automatically pipes its output through a pager (by default: less)."

set -gx LESS_TERMCAP_me \e'[0m' # turn off all appearance modes (mb, md, so, us)
set -gx LESS_TERMCAP_se \e'[0m' # leave standout mode
set -gx LESS_TERMCAP_ue \e'[0m' # leave underline mode
set -gx LESS_TERMCAP_so \e'[30;44m' # standout-mode – info
set -gx LESS_TERMCAP_mb \e'[01;31m' # enter blinking mode
set -gx LESS_TERMCAP_md \e'[01;38;5;75m' # enter double-bright mode
set -gx LESS_TERMCAP_us \e'[04;38;5;200m' # enter underline mode

Anyway, you can try it.

There is another discussion thread: https://github.com/sharkdp/bat/issues/1053, I guess we won't need it once bat gets its own pager.

c02y avatar Jun 10 '25 18:06 c02y