In Terminal, let's say I type a long command, but before I press Enter, I decide that actually I don't want to run this command, and want to run another new command instead.

In such case, how to quickly remove everything I have typed, so that I can start typing the new command?

Pressing Delete for a few long seconds is not a good solution, I am looking for something faster.


You can cancel current command with ⌃ CTRL+c. You can clear command to the beginning with ⌃ CTRL+u. To clear line after the cursor press ⌃ CTRL+K.

Here are some great answers on StackOverflow.

  • The crt + u one is a good one to know. crtl + k does not work. The only similar one I know to that is cmd+k which clears all visible history from the window. – markhunte Sep 22 '14 at 8:23
  • 2
    @markhunte if you are in the middle of the command line you are editing, ctrl-k will delete from the cursor to the end of the line – nohillside Sep 22 '14 at 8:26
  • 2
    "crtl + k does not work." It definitely works for OS X default key mappings. It deletes everything after the cursor. "ctrl+a" takes the cursor to the beginning of the line. – Trane Francks Sep 22 '14 at 8:26
  • @patrix , Ah I get you. I was at the end of the line. so had nothing to clear. Doh.. Good tips here. – markhunte Sep 22 '14 at 8:36

You can just use cmd + . to stop and go to a new command prompt on a new line.

It will not erase what you typed. But more importantly it will not execute it.


Terminal natively supports basic Emacs key mappings. As such:

Press Ctrl+a to move the cursor to the beginning of the line and then Ctrl+k to delete to the end of line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .