8

If you have written a really long command, say cd /very/long/path, and then you do ctrl+c or ctrl+u (if the cursor is at the end), and then you realise that you want the command back, is there any way to get the full line back without re-typing. Is there any trick to change .bashrc so that bash_history keep track of keys pressed on the shell and not just after the enter is hit.

I have answered a question at In bash, how does one clear the current input? and realised if we have some option like this it would be very helpful.

Community
  • 1
  • 1
vks
  • 309
  • 4
  • 12

1 Answers1

11

To undo, use either

  • Ctrl+X, Ctrl+U; or
  • Ctrl+_ (underscore).

See bind -P for a full list of keybindings in bash.

Sparhawk
  • 1,581
  • 1
  • 19
  • 29
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • Thanks John, I appreciate your corrections. I will be more careful for rest of my posts. – vks Jun 29 '09 at 03:47