Skip to content
Bruno Heridet edited this page Oct 30, 2020 · 6 revisions

How to get the process id of the current kakoune client?

if you run this in the kakoune command line:

echo %sh{ echo $$ }

You'll get a random number, corresponding to the PID of the temp subshell used to run the command. You need the PID of the parent, which translates to :

echo %sh{ echo $PPID }

Why should printf be favored over echo?

https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo

Passing options and values to an expansion

In kakoune's shell expansion, any $kak_ variable will be expanded before the execution of the shell script.

For example:

evaluate-commands %sh{
    echo "echo -debug $kak_selection"
    echo "execute-keys x"
    echo "echo -debug $kak_selection"
}

Will do the same as:

evaluate-commands %sh{
    echo "echo -debug $kak_selection"
    echo "echo -debug $kak_selection"
}
execute-keys x

To print the whole line selected by execute-keys x you must do

evaluate-commands %sh{
    echo "echo -debug $kak_selection"
    echo "execute-keys x"
}
evaluate-commands %sh{
    echo "echo -debug $kak_selection"
}

See also

AWK

Clone this wiki locally