Currently, I have bindings for comint-previous-matching-input-from-input and comint-next-matching-input-from-input.

My problem is this. Suppose I am on a prompt with some text (say, "x = ") and issue previous - the latest command shows up (e.g. "x = 10"). But now, when I issue next, nothing happens. I understand - no input is matched, so the latest command stays. Instead, I want the original text to show up ("x = ") (if you are familiar with zsh input completion, this is it).

How can I do this?

1 Answer 1


I cycle using comint-previous-input and comint-next-input. So, if I had entered previously x = 1 and x = 2; when I enter x = [cursor] the above two comint commands cycle the previous entries backward and forward. But it won't go back to x = as it is not in the history. You can just kill to the end of line at any point to get x = again.

  • you are right, this is probably the best way. especially that there is helm-comint-input-ring which can do the searching. And in case someone stumbles upon this, I think what's in the question can be done by finding that "History item #" message in the source code and doing some bookkeeping on key presses. Commented Feb 26, 2019 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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