Bash – How to cancel and keep reverse-i-search

bashcommand historyline-editor

Often I fail to find something with reverse-i-search but want to keep what I have already written. For example, typing pdflatex fails to complete to pdflatex mydocument.tex. If I then cancel it with Ctrl+c or Ctrl g, the pdflatex part is deleted as well. How can I cancel it in a way that keeps my input?

Best Answer

Instead of cancelling just use ALT+F (or on Ubuntu alternatively CTRL+-> to move the cursor to the end of the first word and then press CTRL+K to delete everything to the end of the line.

Now you are ready to complete your command.