0

I'm using Windows Terminal (TERM=xterm-256color) in a bash shell under Ubuntu:

uname -a
Linux xxxxxxx 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I'm using vi command line editing mode (set -o vi, in .bashrc on both systems) and everything works as expected.

When I ssh to a bsd machine:

uname -a
FreeBSD yyyyyyy 11.1-RELEASE FreeBSD 11.1-RELEASE #0: Fri Apr 20 14:32:29 EDT 2018     root@zzzzzzz:/usr/obj/usr/src/sys/BBKERN  amd64 

The insert mode no longer works as expected. In insert mode instead of pushing text right it just overwrites the text. However, when the command is processed (i.e. I hit enter) it's clear the text has been inserted and not overwritten.

From looking around I'm guessing this is something I would address in .inputrc (?) Unfortunately, I don't know how to get the key value that Win Terminal is sending or that BSD is wanting.

I'll note that inserts work as expected in the vi editor.

Does anyone know how I can fix this or how I can get the expected keycodes?

1 Answer 1

0

Ok, tracked this down to something rather simple. I was using $TERM = "xterm". Changing that to "rxvt" fixed the issue. Clearly there was something different about the terminal capability definitions for these two terminal types. Digging in the terminfo page I found the 'ich1' cap code. Testing this I see:

> uname -a;echo $TERM
Linux d10c167 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
rxvt-unicode
> tput smir|od -ba;tput rmir|od -ba;tput ich1|od -ba
0000000 033 133 064 150
        esc   [   4   h
0000004
0000000 033 133 064 154
        esc   [   4   l
0000004
0000000 033 133 100
        esc   [   @
0000003


> uname -a;export TERM="xterm";echo $TERM
Linux d10c167 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
xterm
> tput smir|od -ba;tput rmir|od -ba;tput ich1|od -ba
0000000 033 133 064 150
        esc   [   4   h
0000004
0000000 033 133 064 154
        esc   [   4   l
0000004
0000000


name -a;echo $TERM
FreeBSD xxxx.yyyy.zzz.com 11.1-RELEASE FreeBSD 11.1-RELEASE #0: Fri Apr 20 14:30:50 EDT 2018
rxvt-unicode
>  tput im|od -ba;tput ei|od -ba;tput ic|od -ba
0000000   033 133 064 150
          esc   [   4   h
0000004
0000000   033 133 064 154
          esc   [   4   l
0000004
0000000   033 133 100
          esc   [   @
0000003


> uname -a;echo $TERM
FreeBSD xxxx.yyyy.zzz.com 11.1-RELEASE FreeBSD 11.1-RELEASE #0: Fri Apr 20 14:30:50 EDT 2018
xterm
tput im|od -ba;tput ei|od -ba;tput ic|od -ba
0000000   033 133 064 150
          esc   [   4   h
0000004
0000000   033 133 064 154
          esc   [   4   l
0000004

From the above link:

   Terminfo  can  describe both terminals which have an insert mode, and
   terminals which send a simple sequence to open a  blank  position  on
   the current line.  Give as smir the sequence to get into insert mode.
   Give as rmir the sequence to leave insert mode.  Now give as ich1 any
   sequence  needed  to  be sent just before sending the character to be
   inserted.  Most terminals with a true insert mode will not give ich1;
   terminals which send a sequence to open a screen position should give
   it here.

In my case the terminfo on the Ubuntu supported smir, rmir and ich1. However on the FreeBSD machine the termcap defined im, ei but not ic. Seems like it should work but it clearly needs the ic which it doesn't have. Interesting if I run xterm& (the xterm application) from the FreeBSD command line it reports as an TERM="xterm" and the insertion works as expected.

So if you find yourself in a similar situation, see if the terminal you are using supports the proper insert codes for the given OS and terminal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .