delete button in console

Ian Smith smithi at nimnet.asn.au
Wed Dec 30 14:34:02 UTC 2015


In freebsd-questions Digest, Vol 604, Issue 3, Message: 17
On Wed, 30 Dec 2015 06:05:29 +0100 Polytropon <freebsd at edvax.de> wrote:
 > On Tue, 29 Dec 2015 14:53:32 -0553.75, William A. Mahaffey III wrote:
 > > On 12/29/15 11:14, Polytropon wrote:
 > > > On Tue, 29 Dec 2015 01:48:49 -0800, Sergei G wrote:
 > > >> When I ssh to a FreeBSD machine and press 'Delete' button in csh prompt
 > > >> I get character '~' printed on screen.  Backspace works just fine.
 > > >>
 > > >> I think even an actual console behaves the same way.
 > > >>
 > > >> Is there a way to "map" the Delete button to work appropriately? Would
 > > >> it be my SSH client application or FreeBSD itself?
 > > > This is a thing that can be configured for the shell. I assume
 > > > you're using FreeBSD's default dialog shell, the C shell. In
 > > > this case, add to ~/.cshrc:
 > > >
 > > > 	bindkey ^? delete-char		# for console
 > > > 	bindkey ^[[3~ delete-char	# for xterm
 > > >
 > > > Or to /etc/csh.cshrc, if you want to make it a global setting.
 > > >
 > > > You can check the success with the "stty -a" command.
 > > 
 > > 
 > > Is this keyboard dependent ? My keyboard apparently sends '^?' for its 
 > > backspace key.
 > 
 > No, this is a matter of terminal emulation. The keyboard usually
 > sends the same position code (or ASCII code) everywhere in the
 > world. If I remember correctly, Backspace is 0x08, and Delete is
 > something else.

Native delete key is 0x7f, the last ASCII character.  Goes way back .. 
but I can't remember the EBCDIC equivalent :)

 > > When I try the above, then 'stty -a', I see no setting.
 > > 
 > > [wam at devbox, pre, 2:48:10pm] 2029 % bindkey '^?' delete-char
 > > 
 > >      <try 'vi' on an ASCII file, BS key still doesn't work> ....
 > 
 > That may be a vi thing - I've tried it here, and backspace does
 > not do what it usually does in vi (neither in "insert" or "vi" mode).
 > At the regular console prompt, it works as intended (and in all
 > other text mode editors, like ee, too).

 > > I am actually using rxvt, logged into another box, but it apparently 
 > > advertises as xterm ....
 > 
 > Is the .cshrc setting being made on _that_ box (the target box)?
 > If the rxvt is configured "xterm-compatible", make sure you also
 > have the xterm setting. Compare:
 > 
 > 	bindkey ^? delete-char		# for console
 > 	bindkey ^[[3~ delete-char	# for xterm
 > 
 > It's helpful to define both.

Indeed.  Long ago when first getting this going, I found it necessary to 
explicitly add 'stty erase ^H' after fixing the delete (forward) char/s 
in ~/.cshrc; I forget why, but likely couldn't hurt (William) to try ..

if ($?prompt) then
        # An interactive shell -- set some stuff up
        set prompt = "$USER on `/bin/hostname -s`% "
        set filec
        set history = 1200
        set savehist = 900
        set ignoreeof           # no exit on ^D
        set mail = (/var/mail/$USER)
        if ( $?tcsh ) then
                bindkey "^W" backward-delete-word
                bindkey -k up history-search-backward
                bindkey -k down history-search-forward
                bindkey "^?" delete-char
                bindkey "\e[3~" delete-char
                bindkey "\e[1~" beginning-of-line
                bindkey "\e[4~" end-of-line
                set autolist ambiguous
        endif
        stty erase ^H
endif

cheers, Ian


More information about the freebsd-questions mailing list