2

In Bash and other shells in emacs mode, there are these awesome kill/yank shortcuts (see man readline), for example:

  • Ctrl+k: "kill-line": this deletes (and save into a cut buffer) all the current line before the cursor.
  • Ctrl+y: "yank" will paste under the cursor the last deleted content.
  • Alt+y: "yank-pop" will cycle through previous deleted content.

However I am in a situation where I want to:

  1. hit Ctrl+k,
  2. do stuff (type other commands),
  3. and then paste back the original line, but only if there was any content!

In the current settings, hitting Ctrl+k on an empty line leaves the cut buffer unchanged, so hitting Ctrl+y does not *restore* the original line.

I can't find how to clear this kill ring, is it doable (apart from switching to zsh...)?

Your Answer

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

Browse other questions tagged or ask your own question.