Help passing command line output `edit` command

Hi!

I’m just starting my Kakoune journey and have many questions. Here is one of them: I could not pass command line output to edit command.

This line outputs currently selected file in Broot to standard output: br --conf ~/.config/broot/select.hjson.

Now I want to pass this output to Kakoube edit command. Here is my attempt:

define-command open_file %{
  edit  %sh{br --conf ~/.config/broot/select.hjson}
}

Unfortunately, this opens empty file with no name, so nothing was passed to edit. What am I doing wrong? The file withe current date name is succsessfully created the I enter something like this:

define-command open_file %{
  edit  %sh{date}
}

What’s the difference?
Thank you for help!

Kakoune doesn’t give the terminal to its child processes.
Similar to nohup br --conf ~/.config/broot/select.hjson | cat
If that command works, then it should also work in Kakoune.

If you want to have a terminal for a sh command, consider using the :terminal command.

Got it, thank you!

Ant chance suspend-and-resume can help in this situation?

suspend-and-resume seems to work. Something like this:

define-command test-sar %{
  suspend-and-resume "br --conf ~/.config/broot/select.hjson" "edit <filename>"
}

Unfortunately I have no idea how to save the output of br --conf ~/.config/broot/select.hjson to some variable, to use it later with edit… Any help!

Thank you!

Hello, this is tricky, there are many tools like kcr or kks, which basically help you to abstract away the chore of talking to a given kakoune session, you could check those out, but basically what you would want to do is do your stuff in the shell, and pipe the output to a tool that sends a command to your kakoune session and stores something in an option, you can even use kakoune itself for this, check the --help command, you will see you can execute arbitrary commands at any given session, and kak also has a json rpc api.