Saturday, August 20, 2011

cygwin terminal backspace problem

You just installed cygwin and opened a terminal to use it. If you see that backspace and delete keys does not work in terminal; instead the cursor moves ahead with space. It is strange that initial installation of cygwin has such weird problem. When i face this problem and googled to solve it, nothing worked actually.

Problem was that terminfo files used to define/configure terminal types (vt100, xterm etc.) were not available at expected directory; actually files were installed and existed in C:\cygwin\usr\share\terminfo but were not used by cygwin somehow.

Here is how to resolve it:

1- confirm that problem is terminal type related; run less command for that, it will give a warning:

bash-3.2$ less my_session.log
WARNING: terminal is not fully functional



2- run "infocmp -C" command to learn which path/directory is searched for termcap files:

bash-3.2$ infocmp -C
infocmp: couldn't open terminfo file /usr/share/terminfo/63/cygwin.
bash-3.2$


3- run "cygcheck -s" cygwin configuration diagnostics to learn some path details about /usr/share/terminfo.

bash-3.2$ cygcheck -s

Cygwin Configuration Diagnostics


...
C:/Program Files/ICW               /                    system  binary,noacl

C:/Program Files/ICW/bin           /usr/bin             system  binary,noacl
C:/Program Files/ICW/lib           /usr/lib             system  binary,noacl

C:\Program Files\ICW\etc\terminfo  /usr/share/terminfo  system  binary,noacl
cygdrive prefix                    /cygdrive            user    binary,noacl,posix=0,auto

...

4- copy missing files from /usr/share/terminfo to related directory C:\Program Files\ICW\etc\terminfo; target directory might be different; it depends on windows version and cygwin installation place; below is just two examples for target directories in my test case:

copy C:\Program Files\ICW\usr\share\terminfo directory/files to C:\Program Files\ICW\etc\terminfo or sometimes to C:\Users\<your_username>\AppData\Local\VirtualStore\Program Files\ICW\etc\terminfo

that's it!