2

This question was about how to delete the last word in bash with ctrl-backspace. As already mentioned there, different Linux distros (or different Unices in general) behave differently: Some produce ^H, some produce ^? if Ctrl+Backspace is pressed.

How can I find out in some automatic way (so it can be used in a script) which convention is followed?

viuser
  • 2,614

1 Answers1

2

There is no standard way to ask about control-backspace.

The conventional way to ask about the backspace key is in the terminal database, e.g., look at the output of

tput kbs

If your terminal is configured to match the TERM value, that gives the "backspace" key.

Some terminals (originally rxvt, later xterm and now "several" undocumented) implement control-backspace as the "other" choice (^H where "backspace" sends ^?, etc). Some terminals ignore the control modifier. But for those that use it, that inference is as far as you can go.

Further reading:

Thomas Dickey
  • 76,765