Hello,
I did a command to launch a script to grep word(fzf+rg) in project with the help of connect.kak
.
map global user -docstring 'open FZF fuzzy word finder' g ':@ rfzf;tmux-terminal-zoom 1<ret>'
I launch the script with @ rfzf
and after I zoom the pane in tmux with tmux-terminal-zoom 1
.
I would like to add kakoune selection (should be something like $kak-selection
) in the prompt of the fzf launched script but I can’t find how to add it ? From that I saw in different forum it is not so easy I believed.
Regards
$kak_selection
should work fine in a expanded shell block, such as:
%sh{ echo "$kak_selection" }
You can also expand it as string in kakoune script with %val{selection}
.
I could test with :
@ rfzf;tmux-terminal-zoom 1;%sh{ echo "$kak_selection" }
And the selection is retrieved.
But it is trying to do a third command with the selection.
How could I do to have it in the prompt of fzf
open by the script ?
It really depends on what the rfzf
command and @
does.
Assuming that @
launches some new terminal window with the commands passed as arguments, then you’d probably want to pass $kak_selection
as some kind of argument to the rfzf
command.
Thanks a lot.
You help me to think well.
I solved the issue with :
map global user -docstring 'open FZF fuzzy word finder' g ':@ rfzf %sh{ echo "$kak_selection" };tmux-terminal-zoom 1<ret>'
For information, if someone need it, the rfzf
script is as :
#!/usr/bin/env bash
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="${*:-}"
: | fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q}" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3' \
--bind 'enter:become($EDITOR {1} +{2})'
And I use the plugin connect.kak for the command :@ rfzf
:
kakounedotcom/connect.kak: Connect a program to Kakoune clients (github.com)
In this case you should use the value directly instead of spawning a shell just to get it back. $kak_selection
is automatically injected in shell environment with the value of %opt{selection}
, so it’s a roundabout way.
Try this instead:
map global user -docstring 'open FZF fuzzy word finder' g ':@ rfzf %val{selection};tmux-terminal-zoom 1<ret>'