In bash
pressing CTRL + U clears the characters on the line before the current cursor position while in zsh
this will clear the entire line. How do I clear the characters on the line before the current cursor position by pressing CTRL + U in zsh
?
Asked
Active
Viewed 9,714 times
2 Answers
20
Bash and zsh work slightly different here. In zsh, CTRL + U clears the entire line instead.
Add these lines into your configuration .zsh:
bindkey -e
bindkey \^U backward-kill-line
You can use
$ bindkey
to list all of your keyboard shortcuts in zsh.
BTW: in bash you will print all bindkey with the following command:
bind -P
So no cheat sheets are necessary!

abu_bua
- 10,783
6
In zsh, Alt+W deletes the from the cursor back to the beginning of the current word.
-
That is an important answer that gives the WHY, thanks for this precision – itMaxence Apr 04 '23 at 16:12
-
On my Mac Alt defaults to option for alternate characters. Esc+k works though. – Karl Mar 27 '24 at 23:41
bindkey "\Cu"
report? – muru Jun 19 '18 at 11:17bindkey \^U backward-kill-line
. @muru"^U" backward-kill-line
– menteith Jun 19 '18 at 11:18