On Sat, Feb 11, 2006 at 05:17:29PM -0500, Nick Guenther wrote:
> Yeah, it does that. I don't know why, I assume historical reasons, and
> I would like to learn from someone here who does know. Use backspace
> instead.
> 
> On 2/11/06, Martin Schrvder <[EMAIL PROTECTED]> wrote:
> > Hi,
> > on my freshly installed 3.7 in bash the delete key sends an ~
> > instead of [del]. How can I fix this?

  it *is* sending del.  rather, the characters sent when you strike the
  delete key are recognized by the shell and the shell executes the 
  editing command "delete-char-backward".   problem is it also sends 
  a tilde after the sequence that the shell recognizes.

  ^[[3~ is what i get here if i just go to a normal console terminal
  and hit delete.  that is one character more than my shell is listening
  for.

  i believe, at least with respect to ksh, bound keys are editing commands
  that are executed when the shell sees a a control character, which may 
  be have a prefix-character in front of it, come across. 
  the ksh manpage (/ for bind) describes it better than i do, 
  but basically, look at it like this:

  ^[[3~ is three parts.  ^[[, 3, and ~.  ^[[ == ^X, 3 == 3, ~ == ~.

  when the shell sees that, it recognizes "^[[" as 'prefix-2', or ^X.
  ^X3 is (i think?) set to 'delete-char-backward'.  at that point, the shell 
does
  that.  the ~ was not part of the sequence of keys the shell recognized
  because it is too many chars.  you get a "prefix" and a "control char",
  not a prefix and two control chars.  if you type:

blah

  and hit 'delete', usually you'll end up with

bla~

  because it did the delete-char-backward, which killed the 'h', but then
  the '~' showed up after any shell-recognition was done and so it made
  it out to the terminal as a normal character.

  a hackish way around that is to use '-m' and make it so
  that the shell substitutes "^[[3" with a control-X.  eg:

$ bind -m '^[[3'='^X'

  ( where '^X' isn't "<shift>-<6>, <shift>-<x>", but rather:
  "<control>-<v>, <control>-<x>". )

  and then 

$ bind '^X~'=delete-char-backward

  which makes it to that when the shell sees '^[[3', it substitutes that for
  a real ^X.  if i'm hitting <delete>, the ~ is also sent by my keypress,
  but at that point, the sequence has become '^X~', which then executes
  'delete-char-backward'.

  perhaps bash is the same...

-- 

  jared

[ openbsd 3.9-beta GENERIC ( jan 30 ) // i386 ]

Reply via email to