I see in the documentation for the prompt
command that there are completions for buffers, clients, commands, and then the “call out to shell” option. Is it somehow possible to do “word=all” completion for a prompt?
Here’s what I’m looking to use it for, maybe I’m looking in the wrong place, or trying to fit a square peg in a round hole…
I have a command that either runs grep with whatever text is currently selected in the buffer, or prompts for input if there is nothing selected (selection length === 1). This allows me to use the same command for either “I want to grep something…” or “I want to grep the thing I currently have selected”. I find this reduces mental friction for me:
def grep-or-prompt \
-docstring 'Grep current selection if greater than 1 character, or prompt for input' \
%{ evaluate-commands %sh{
if test "${#kak_selection}" -gt 1 ; then
escaped=$(echo $kak_selection | sed "s/'/''/")
printf "
grep '$escaped'
"
else
echo "prompt grep: %{ grep %val{text} }"
fi
}}
Ideally, I’d like that prompt call to utilize the “word=all” completion, but it looks like prompt doesn’t support that for some reason…can anyone think of how I might be able to work around that? Am I just going about this in the wrong way?