In bash, how to do a control-delete middle word kill?

Bash uses readline, and readline can remove the word to the right of the cursor with "kill-word".

The problem is recognizing the control-delete key press. When I click them on bash, "5 ~" is displayed. I could just attach to this, but that would mean that one day I need to type “5 ~” and instead it will delete the word on the right! Therefore, I would rather find the correct control sequence.

I have googled and quite a few resources discuss the delete key, but none of them I found discuss the control-delete key. I experimented with many options, but nothing works.

The worst is the hours I spent on this tedious, pointless shredding, when it really should be a problem.

EDIT: via X, so maybe there is a solution with xev and xmodmap

+3
source share
5 answers

On my machine, pressing Ctrl-V, Ctrl-Delete displays this:

^[[3;5~

The control character ^[can be replaced with \ e, so you can use bind like this for bash (e.g. in ~/.bashrc):

bind '"\e[3;5~":kill-word'

Or you can add the following to your own ~/.inputrcso that Ctrl-Delete does kill-word in any program that uses readline:

"\e[3;5~": kill-word

This will only bind the Ctrl-Delete key, you do not need to worry about what happens if you need to enter 5 ~.

+10
source

, , . <ESC>5~ - . Ctrl-V Ctrl-Delete. Ctrl-V " ".

, <ESC>5~, .

+3

^ Q ^ V ( Control-Q, Control-V, ), Control-Delete, ? , , , Putty, . , Linux .

readline , , . , ^ Q ^ V (, , quoted-insert).

, ^ Q ^ V, Delete ( ), readline ^[[3~. , Delete, \e[[3~. , CSI , , readline .

+2

Alt + D Ctrl + W ( Emacs, )

+2

Ctrl-W .

Ctrl-u .

Emacs (M-w M-u).

0

Source: https://habr.com/ru/post/1705260/