3

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.

  • What shell (Bash/ksh/zsh) are you using? – zero2cx Sep 8 '12 at 5:59
6

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.

1

Try Command Line Editing?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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