Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a keyboard shortcut to delete the current command?

Let's say I have:

$ cp /home/one/two/tree/ /var/www/one/two/three

I want to easily the current command, specially when it's long and I had a typo. The up and down history selection doesn't remove the current command at all.

share|improve this question
    
What shell (Bash/ksh/zsh) are you using? –  zero2cx Sep 8 '12 at 5:59

2 Answers 2

up vote 5 down vote accepted

Assuming your shell is bash, this question has been asked and answered on SO.

Press Ctrl-U to delete the command line from the location of the cursor up to the beginning. Precede this by Ctrl-E if the cursor isn't at the end of the line.

Or press Ctrl-C to cancel the current prompt and obtain a new one, which has the benefit that you still see the command you typed.

As bash is highly customizable, the above should work in a default setup, but you or your package provider might always reconfigure the shell for a different set of shortcuts.

share|improve this answer
    
thanks so much! –  Pineapple Under the Sea Sep 8 '12 at 8:50

Try Command Line Editing?

If you are using Bash, check: http://www.gnu.org/software/bash/manual/html_node/Command-Line-Editing.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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