The following function
function test_hist() {
print -s "This is a test"
}
zle -N test_hist
bindkey '^X^T' test_hist
adds the string This is a test
to the zsh-history.
If I call the function explicitly by typing test_hist
, the string is immediately added to the history, but if I call it through the bindkey by pressing ctrl-x ctrl-t, the string is not added to the history straight away. I need to issue another command before I can see it in the history.
Why is that, and how can I fix it?