I’m using a similar hook which handles everything in one command:
hook global BufCreate [^*].* %{
nop %sh{
mru=~/.cache/kak-mru
echo "$kak_buffile" | awk '!seen[$0]++' - "$mru" | sponge "$mru"
}
}
I then execute this script from kakoune to get a list of files in fzf (uses kakoune.cr):
~ > cat .local/bin/kcr-fzf-mru
#!/bin/sh
# Jump to recent file in Kakoune.
kcr edit "$(fzf < ~/.cache/kak-mru)"