If I have this:

$ bla bla bla bla

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

link|improve this question

feedback

2 Answers

up vote 5 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.

link|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
show 1 more comment
feedback

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
link|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 at 17:14
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.