Clear a line in the terminal
By John Campbell •
I sometimes start writing a command in the terminal (iTerm2) which half-way written I want to erase.
How can quickly remove all the characters on the line being worked on in the terminal?
1 Answer
Press Ctrl-C. This will essentially start a new line.
To clear everything before the cursor position, use Ctrl-U.
To clear everything after the cursor position, use Ctrl-K.
These are some of the basic Bash keyboard shortcuts.
1