Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I have this:

$ bla bla bla bla

Is there any shortcut for Terminal (MacOS) to clean the entire line?

share|improve this question
up vote 10 down vote accepted

The command to discard (kill) the whole line is not usually assigned a keyboard shortcut. Ctrl-U will only kill from the beginning of the line to the cursor.

Press both Ctrl-U (prefix) and Ctrl-K (suffix) to remove the whole line, no matter where the cursor is.

Here's a bash reference with the different commands and their default keyboard shortcuts.

You can assign a keyboard shortcut to kill-whole-line by editing ~/.inputrc. Add the following line:

"\C-k": kill-whole-line

This will assign Ctrl-K the "kill whole line" command.

share|improve this answer
    
you're correct for most linuxes, but on OSX C-u clears the whole line not just behind the cursor position. – Ted Naleid Jan 9 '11 at 0:19
    
@Ted Naleid: In Snow Leopard it just removes from the beginning of the line to the cursor. – Nerian Jan 9 '11 at 1:07
1  
Sorry, my mistake. I use zsh, not the default bash shell, and in zsh it deletes the whole line. Deleting the whole line (regardless of cursor position) is also the behavior in cocoa-based controls (such as the firefox address bar), so I assumed that was the bash behavior too. Just tested in bash shell and the behavior described by Daniel in the answer matches. – Ted Naleid Jan 9 '11 at 5:18
    
@Ted Naleid: I googled zsh. Looks quite interesting. I might install it on my macbook after the exams :) – Nerian Jan 10 '11 at 0:12
1  
@Nerian No need to download anything. Change your shell in System Preferences » Accounts » Right-click your account, or change the Terminal shell in Terminal preferences. – Daniel Beck Jan 10 '11 at 7:06

Following is for Linux bash, but I suppose this should work for Mac also:

Clear input line:

Ctrl + U

Another trick is just:

Ctrl + C
share|improve this answer
    
It works, perfect :) – Nerian Jan 7 '11 at 12:08
    
@Nerian: Please don't forget to mark your question as answered! – oKtosiTe Jan 7 '11 at 12:53
    
works perfect. thx! – taiansu Apr 28 '12 at 17:14
    
because everything should be weird on mac, it is command +K, and Ctrl + C – Paschalis Jul 12 '14 at 11:12

You must log in to answer this question.

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