Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Make the forward delete key work in Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Make the forward delete key work in Terminal
Authored by: nschrems on Jun 20, '08 08:41:08AM

The problem is that the applications where the forward delete key doesn't work use the Terminfo terminal database and are probably using the curses library that depends on it ads that is the unix toolbag for writing terminal-independent programs.

In the course of trying to port a curses-depended program I wrote some years ago on a Sys V system to work in Terminal.app, I spent a bunch of hours messing around with the problem and finally solved it.

The problem is that the terminfo description of the vt100 which is the default emulation mode for Terminal.app doesn't contain a definition for the forward delete key. Furthermore, although the vt102 definition does contain a definition for dch1, I discovered that is not the correct capability to define. Apparently dch1 is the code to SEND to a terminal to have it forward-delete 1 character on the screen. Mapping the forward delete key is done with kdch1.

Now for the cookbook!
Open a Terminal.app and cd to directory with some room to play.

$ infocmp > termdef.tmp (Decompiles terminfo file for the current term type)
$ vi termdef.tmp (Going to edit the decompiled version)
-----
add the following definition
kdch1=\E3~
You can stick it in anywhere, I stuck it in a line with some other keypad definitions like:
kcuu1=\EOA, kdch1=\E[3~, kent=\EOM, kf0=\EOy, kf1=\EOP,
-----
Now recompile the term definition file
$tic terminal.tmp

That's it. You probably need admin privilege for the last step so you may have to sudo it.

If you log onto a remote server, it is the server version of the definition file that matters. If you control the server -- no problem. Just do the above stuff there. If you don't control it, you can still do an infocmp and see if kdch1 is defined. To avoid looking for it yourself, try
$infocmp | grep kdch1
If it is defined there, you can make your keyboard mapping match the definition there. If it is not defined there, you can make your own copy of it. Do everything the same as above except when you get to compiling it, use
$tic -o <dir> terminal.tmp
Probably best if <dir> is your home directory.
Set an environment variable TERMINFO to whatever you used for <dir>. This will cause programs to use your private copy of the terminal definition.



[ Reply to This | # ]