bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The backspace key can only move forward and cannot delete characters


From: Chet Ramey
Subject: Re: The backspace key can only move forward and cannot delete characters
Date: Wed, 20 Mar 2024 14:31:56 -0400
User-agent: Mozilla Thunderbird

On 3/20/24 11:54 AM, G. Branden Robinson wrote:
At 2024-03-20T09:12:20-0400, Chet Ramey wrote:
On 3/19/24 9:38 PM, 高剑平 wrote:
May I ask how to bound to `delete-char' instead of
`backward-delete-char'.

This is backward; it sounds like you want to bind it to
backward-delete-char.

1. Find out what key sequence your backspace key emits. This is
    terminal- specific, but you might be able to find it in your
    terminal app's settings. Let's say it's \033[3~

(I'll speak of Bash rather than readline in this message; that is
because the readline library is bundled with Bash and Chet maintains
them together.  Formally, Bash is merely a readline application.)

Yes, though bash exercises more of readline's features than most other
applications, with the possible exception of gdb.


I would add that there are a couple of approaches you can take to this.

These are all valid.


2. Bind that sequence to the desired command in ~/.inputrc

"\033[3~":backward-delete-char

Keep in mind that the ^ shorthand for control needs to be \C- in readline
key bindings. For instance, if you want to bind what terminfo (and the tty
driver) shows as ^?, you need to use \C-?.


[1] As I understand it, Bash has for a long time shipped its own
     "vendored" version of the GNU termcap library (which has been
     unmaintained for about 30 years), but it supports using the termcap
     API of the system's curses library if it offers one (ncurses does).

A last-ditch default so that bash links successfully. It probably works ok
if the termcap entry is in the TERMCAP environment variable.


     (This probably can't be taken for granted; the X/Open Curses
     standard withdrew the termcap API in Issue 7--2009--but I reckon
     System V Unix vendors lazily kept right on doing whatever they'd
     been doing for years, offering the termcap API or not.  Chet likely
     has more insight into what deployments look like thanks to Bash
     configuration/bug reports from relevant OSes.)

Most distros make readline depend on ncurses, which continues to provide
the termcap compatibility functions.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]