Delete current command

3

1

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.

Jürgen Paul

Posted 2012-09-08T04:57:53.970

Reputation: 715

What shell (Bash/ksh/zsh) are you using? – zero2cx – 2012-09-08T05:59:56.463

Answers

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.

MvG

Posted 2012-09-08T04:57:53.970

Reputation: 1 259

1

Try Command Line Editing?

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

damage3025

Posted 2012-09-08T04:57:53.970

Reputation: 11