MacOS – command + delete in terminal

keyboardmacosterminal

Often, when I'm typing in a super long command(usually ruby on rails console code), I decide that I need to do something else first and therefore, have to delete the command which I just typed(but not executed) on the terminal. Is there a shortcut to do this? command+delete and option+delete do not work. The down arrow works sporadically.

If it helps, I'm on The El Capitan Developer Preview 3 but I've noticed this behaviour on Yosemite as well.

Best Answer

If you are using emacs keybindings (default for bash, zsh, pry (ruby interpreter), python and many more), ^u (control + u) might be what you want - it erases everything prior to your cursor. If you want to stop writing the command and forget what you did, use ^c (control + c), which is, by the way, a SIGKILL(9) signal (see man signal).

By the way, the keybindings not only work on OS X 10.11, but also on all Unix-like systems I've ever seen.