Better living through software

Ben Hutchings's diary of life and technology

Email: • Mastodon: • Debian: benh (Salsa, QA) • Gitweb: • GitHub: bwhacks

Sat, 22 May 2010

Cancelling a command in bash

Rogério Brito writes:

[...] whenever I was typing a command line, changed my mind and pressed C-c, I got a ^C printed on the screen, usually overwriting one or two characters of what I had typed. And this prevented me from automatically copying and pasting the command that I had typed.

There is an alternative to using C-c, and that is M-#. This adds a '#' to the start of the line, commenting it out, and then behaves as if you pressed Return. The result is that the command is cancelled but still remains on-screen and in your history. You can then copy the command later using the mouse or keyboard.

posted at: 23:56 | path: / | permanent link to this entry