I am learning terminal tips. In this tutorial, the guy says that Ctrl + U deletes everything from the cursor until the end of line. In my case, it always deletes the whole line. I am using zsh
on macOS.
2 Answers
First map the key binding by typing bindkey \^U backward-kill-line
. Then test to see if this worked. If it works, make it permanent by adding the same line to an appropriate zsh
RC file.
echo 'bindkey \^U backward-kill-line' >> ~/.zshrc
The Z Shell Manual, section 18.6.3, defines the "widgets," such as backward-kill-line
.
-
1
if youre talking about GNU readline in the shell you will want to use Ctrl+K to kill to the endof the line.
Alternatively you can also use Alt+D to incremently kill on a breaking point
Edit: Just realized you're using zsh on Mac. The only server I haveusing zsh is in the cloud. Ill test real quick and verify.
Edit: Yes still works for me on Linux Ubuntu. Note that I installed zsh (and fish which is quite nice) on that machine about 2 weeks ago and never made a zshrc file. So there has been no special customizations as far as I can tell. Im guessing all these ZSH questions are in regards to what I heard was Apple leaving their ancient version of bash finally because they found something they can conveniently use
Ctrl-U
kills to the beginning of the line. 2:40 into the video.Ctrl-U
deletes between the cursor and the beginning of the line. Of course, if the cursor is at the end of the line then the whole line is deleted.Ctrl-U
on zsh isCtrl-W
. This is why is "doesn't work" as expected. Found it on this askubuntu thread: askubuntu.com/questions/1047849/…