3

What is self-insert is for in zsh? I see it every where in the prezto configs but cannot grasp what it is suppose to do, ZLE documentation is also not specifying what it is, however mentioning it in some different contexts.

3

When bound to a key, this function inserts the key itself as an input character. For example, the key a is bound to self-insert, so pressing the key causes "a" to be input.

From the zshzle(1) manual page (zsh version 5.5.1):

  self-insert (printable characters) (unbound) (printable characters and some con‐
  trol characters)
         Insert a character into the buffer at the cursor position.

For comparison, from the readline(3) manual page (bash version 4.4.023):

  self-insert (a, b, A, 1, !, ...)
         Insert the character typed.
1

From the documentation,

Any other character that is not bound to self-insert or self-insert-unmeta will beep and be ignored.

I was messing with my shell and bound '.' to a function, then unbound it. Suddenly I couldn't type a dot, anywhere. bindkeys showed "/"-"~" self-insert, but in another clean shell it was "/"-"-" self-insert. The character was completely ignored, even for cut and paste.

To get my dot back, I had to bind it to self-insert:

bindkey '.' self-insert

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.