Fzf.kak with bat and line numbers


I would like to use fzf in Kakoune with bat to have color and line numbers in preview files. I installed also ‘bat’ and the name to call it is ‘batcat’, so I did an alias to use ‘bat’.

I set Kakoune with :

plug "andreyorst/fzf.kak" config %{
} defer fzf-file %{
    set-option global fzf_highlight_command 'Bat'          # I tried also with 'batcat' and 'bat'.

But I have always no color and line numbers (this is working in terminal with commands or fzf settings)

bat somefile will add colors but bat somefile | cat will not because the output is not a terminal.
That’s the conventional behavior. You probably want bat --color=always

I tested with :

plug "andreyorst/fzf.kak" config %{
} defer fzf-file %{
    set-option global fzf_highlight_command 'bat --color=always' 

But It is not working too.

I could solve with (bat is named batcat on ubuntu) :

plug "andreyorst/fzf.kak" config %{
} defer fzf-file %{
    set-option global fzf_highlight_command 'batcat --color=always --style=numbers {}'
  1. Do you know if it possible to have bat color with grep (ripgrep, rg command) ?
  2. Do you know if possible to have a highlight line to see the file line matching in preview for the grep ?

I think this is what you need (at least for 1):

I can see this is coming from kamp kakoune plug in. I’m looking to use kak-fzf which is a public archive. Maybe I wrong to go this way ?

Hi, do you get colors when using fzf_file_command as opposed to fzf_grep_command? I had to set fzf_grep_preview_command (I think it’s undocumented) to get colors in previews when grepping for text. My configuration:

plug "andreyorst/fzf.kak" config %{
  map global user f ": fzf-mode<ret>" -docstring "fzf"
} defer fzf-file %{
  set-option global fzf_file_command 'rg'
  set-option global fzf_highlight_command 'bat'
} defer fzf-grep %{
  set-option global fzf_grep_command 'rg'
  set-option global fzf_grep_preview_command 'bat'

I tried, but not work on my side.
Yet, this is working with popup.kak

I tried again and finally it is working well also on my side to have the color.
There is also the highlight line to show where the grep has found the string.
The plugin is plugin archive but it seems to work well and is stable enough to be used.

I would like to keep it simple by not using a plugin.
But, I can not make it working from a simple shell script with fzf-tmux or using Peneira plugin :