I have successfully bind the Enter key using:

function foo() {
  echo 'Im a foo'

bind -m vi-insert -x '"\C-M": foo'

the problem is I have no way of accepting the READLINE_LINE.

How can I bind the Enter key to an external command then send an accept line as the same time?

I have tried printing newline using this:

function foo() {
  echo 'Im a foo'
  printf "%b" "\n"

but that's just prints a newline after the prompt. not actually accepting the READLINE_LINE.

1 Answer 1


Since it seems not possible to invoke readline's standard accept-line behaviour in a custom enter handler, you can use this: https://github.com/axiros/readline_proxy/

  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Oct 24, 2022 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .