Perhaps I may be a bit of a dummy... but there is no documentation over how to use kak -ui dummy. There's a wiki over kak -c session -ui json < fifo. It's title is rpc json. It would be awesome if I could somehow pipe mere keys to a session headless or otherwise but execute-keys gives an error when ran on a headless session.
I don't think the dummy UI is actually useful for very much. If you want to pipe commands to an existing session, you might be interested in:
echo "some command" | kak -c SESSION -p
...which connects to the given session, and makes it execute commands given on stdin. On the other hand, if you want to do editing from a script, you might use:
kak -f "sfoo<ret>cbar<esc>" file1 file2...
...which opens each file, selects the entire buffer, executes the given keys, then writes the buffer back out. It can also be used in a pipeline.
kak -c SESSION -p is actually kak -p SESSION. I know of kak -f filter-string file1 file2... but this is the first I've heard of the kak filter option being able to be used in a pipeline. How would you use it in a pipeline? Also if the dummy ui isn't useful for much, what is the small amount that you can do with it. As far as I know it does absolutely nothing. Thanks for the insight. Always willing to learn!
Oh and I have tried piping the execute-keys command to a headless session with printf "execute-keys '%s'" '%s\$\d+
# '%s\$\d+\
printf "execute-keys '%s'" '%s\$\d+\
kak -c SESSION -p is actually kak -p SESSION.
Oh, right, sorry.
How would you use it in a pipeline?
Just like it sounds:
$ echo "hello world" | kak -f 'sworld<ret>ckakoune<ret>'
hello kakoune
if the dummy ui isn't useful for much, what is the small amount that you can do with it.
I'm afraid I don't know, we'll see if anybody else chimes in with an answer.
Oh and I have tried piping the execute-keys command to a headless session [...] but it doesn't nothing.
I just tried it myself, and yeah, you're right. I think "kak -p" effectively executes commands in the global context, the same way kakrc is executed. You can't use exec because there's no current buffer for the keys to execute on, and you can't use eval -draft because there's no current selections to save and restore.
You can still use exec -client blah to execute commands in the context of another, already-existing client, though. For example:
# Launch a headless session with a predictable name
kak -d -s test
# Launch a dummy client with a predictable name
kak -c test -ui dummy -e "rename-client dummy" &
# Use kak -p to execute commands in the context of that dummy client
echo "eval -client dummy %{ buffer *scratch*; exec ggiblah<esc> }" | kak -p test
Running kak -ui dummy will start a client named client0 that you can use (with eval -client client0 ...). I have used the dummy ui for headless testing. Another use case is to start a server without a ui to later connect to it.
Thanks! Should I mark this as closed or does anyone have anything to add? You guys are awesomely helpfull
One use I have for the dummy ui is non-interactive text processing. For example, something like
for file do
kak -n -ui dummy "$file" -e 'try %{ some_command_that_can_fail; write-quit } catch %{ quit! 1 }'
done
If you don't use the dummy ui, the terminal will flicker as kakoune is started and stopped right away.
It's a bit like kak -f, but more powerful.
Is execute-keys still not possible with kak -ui dummy -e 'execute-keys some keys' -c SESSION
I guess null could be a better name than dummy for this UI
Most helpful comment
One use I have for the dummy ui is non-interactive text processing. For example, something like
If you don't use the dummy ui, the terminal will flicker as kakoune is started and stopped right away.
It's a bit like
kak -f, but more powerful.