1

How I can use the ctrl+e keyboard combination in emacs mode to go to the end of the line, but also be able to use the End key to do the same? How do I set that with stty? I have tried this combination copied from linux terminal:

stty eol M-^?

but when I press End I get F on keyboard.

The system is old ATT System V on minicom terminal. My term is 386AT and this is terminfo definition

#       Reconstructed via infocmp from file: /usr/share/lib/terminfo/3/386AT
AT386|at386|386AT|386at|at/386 console @(#)386.ti 1.4,
        am, bw, eo, xon,
        colors#8, cols#80, lines#25, ncv#3, pairs#64,
        acsc=``aaffggjYk?lZm@nEooppqDrrsstCu4vAwBx3yyzz{{||}}~~,
        bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[2J\E[H,
        cr=\r, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB,
        cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C,
        cup=\E[%i%p1%02d;%p2%02dH, cuu=\E[%p1%dA, cuu1=\E[A,
        dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[1M,
        ed=\E[J, el=\E[K, flash=^G, home=\E[H, ht=\t,                                                                   
        ich=\E[%p1%d@, ich1=\E[1@, il=\E[%p1%dL, il1=\E[1L,                                                             
        ind=\E[S, indn=\E[%p1%dS, invis=\E[9m, is2=\E[0;10m,                                                            
        kbs=\b, kcbt=^], kclr=\E[2J, kcub1=\E[D, kcud1=\E[B,                                                            
        kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[P, kend=\E[Y,                                                                  
        kf1=\EOP, kf10=\EOY, kf11=\EOZ, kf12=\EOA, kf2=\EOQ,                                                            
        kf3=\EOR, kf4=\EOS, kf5=\EOT, kf6=\EOU, kf7=\EOV,                                                               
        kf8=\EOW, kf9=\EOX, khome=\E[H, kich1=\E[@, knp=\E[U,                                                           
        kpp=\E[V, krmir=\E0, op=\E[0m,                                                                                  
        pfx=\EQ%p1%{1}%-%d'%p2%s', rev=\E[7m, rin=\E[S,                                                                 
        rmacs=\E[10m, rmso=\E[m, rmul=\E[m, setab=\E[4%p1%dm,                                                           
        setaf=\E[3%p1%dm,                                                                                               
        setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,                                    
        setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,                                    
        sgr=\E[10m\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p4%t;5%;%?%p6%t;1%;%?%p9%t;12%;%?%p7%t;9%;m,                        
        sgr0=\E[0;10m, smacs=\E[12m, smso=\E[7m, smul=\E[4m,   
2
  • is the remote side using readline by any chance? an .inputrc of "\e[4~": end-of-line would do it, if so.
    – Jeff Schaller
    May 18, 2016 at 16:05
  • no readline,old unix of 80's
    – elbarna
    May 18, 2016 at 18:39

1 Answer 1

8

That eol setting is not for the key that would take you to the end of some line-editing buffer, that's a setting of the tty line discipline.

It is for its very basic line editor, the one used when entering input for applications (like cat, sed) that don't have their own line editor. That editor doesn't have cursor positioning, the only editing it can do is via backspace (stty erase), Ctrl+W (stty werase) and Ctrl+U (stty kill) possibly more on some systems.

It is done in the tty device driver itself in the kernel, the applications (cat, sed...) don't see those characters.

The eol setting is only to tell that driver to recognise a different (additional) character from linefeed (aka newline aka ^J) as the line ending character. Upon entering that character, the line discipline would send the characters entered so far to the reading application.

For instance, to input text one word at a time instead of one line at a time, you could do:

stty eol ' '; cat

And you'd see that each time you press space, cat would output the text you've entered (including that space character).

If you're at the prompt of a command that implements its own line editor, then making End move the cursor to the end of the current buffer would not be done via stty but by specific configuration of that command (if at all).

For instance, with the zsh shell, that would be done with:

bindkey '^[[F' end-of-line
bindkey '^[OF' end-of-line

Assuming your terminal sends the <ESC>[F or <ESC>OF character sequence when you press that End key as your "F" suggests.

Some application will automatically bind End to their _end-of_line_ action. To do that, they will query the local termcap or terminfo terminal databases to find out what character sequence your terminal sends upon that key press.

For that, they use the $TERM variable. If the entry for that key in that database does not match what your terminal sends, then that won't work.

You can try:

tput kend | sed -n l

To see what the database things the End key sends if your tput uses terminfo or check for your $TERM entry in /etc/termcap if using termcap. You may be able to find an entry there that more closely matches your minicom (or the terminal emulator that hosts it) behaviour.

Edit based on new info

So, most likely, you're running minicom in a modern xterm-like terminal and communicating over serial. At the other end of the serial line, getty assumes you're running an at386 console (which I believe is actually the internal console driver of old PC-based AT&T systems). That is very far from a modern xterm.

Looking at a Solaris system here which in many respects is about as modern as your old AT&T system, there is a xterm entry in terminfo but it lacks the kend capability.

What you could do is upload the terminfo definition of your terminal on the machine you run minicom on (infocmp > file), transfer that to the SysV machine, and try and compile it over there with tic (and set $TERM to the same value of there, set the TERMINFO environment variable beforehand to something like ~/.terminfo if you're not administrator there). If that doesn't work because the curses version is too ancient, you could use the vt100 entry of the AT&T system instead, and just edit in the kend=\EOF of your terminal, change the name and use tic again.

Like:

cat > my-term.info << \EOF
my-term|My VT100 compatible terminal with an end-key,
    am, mir, msgr, xenl, xon,
    cols#80, it#8, lines#24, vt#3,
    acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
    bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>,
    clear=\E[H\E[J$<50>, cr=\r, csr=\E[%i%p1%d;%p2%dr,
    cub=\E[%p1%dD, cub1=\b, cud=\E[%p1%dB, cud1=\n,
    cuf=\E[%p1%dC, cuf1=\E[C$<2>,
    cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA,
    cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>,
    el1=\E[1K$<3>, enacs=\E(B\E)0, home=\E[H, ht=\t,
    hts=\EH, ind=\n, ka1=\EOq, ka3=\EOs, kb2=\EOr, kbs=\b,
    kc1=\EOp, kc3=\EOn, kcub1=\EOD, kcud1=\EOB,
    kcuf1=\EOC, kcuu1=\EOA, kent=\EOM, kf0=\EOy, kf1=\EOP,
    kf10=\EOx, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\EOt,
    kf6=\EOu, kf7=\EOv, kf8=\EOl, kf9=\EOw, rc=\E8,
    rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O, rmkx=\E[?1l\E>,
    rmso=\E[m$<2>, rmul=\E[m$<2>,
    rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
    sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t^N%e^O%;,
    sgr0=\E[m^O$<2>, smacs=^N, smkx=\E[?1h\E=,
    smso=\E[1;7m$<2>, smul=\E[4m$<2>, tbc=\E[3g, kend=\EOF
EOF
TERMINFO="$HOME/.terminfo" export TERMINFO
mkdir -p "$TERMINFO"
tic my-term.info

And add:

if [ "`tty`" = "the-serial-device" ] && [ "$TERM" = at386 ]; then
  TERMINFO=$HOME/.terminfo
  TERM=my-term
  export TERM TERMINFO
fi

to your ~/.profile (where the-serial-device is whatever tty outputs when you login over serial.

13
  • Line disciplines have been in use before the late 1980s. Since the POSIX tty mode system was introduced around 1987, line disciplines are no longer used.
    – schily
    May 18, 2016 at 17:06
  • none of those solution works anyway thanks for answer
    – elbarna
    May 18, 2016 at 18:40
  • @elbarna, there's no solution in there, only explanations, if you tell us what application you're trying to make the End key work with and what you use for $TERM and what the terminfo or termcap entry looks like for that value, we may be able to give a solution. May 18, 2016 at 20:06
  • Hi,i edit the question with new infos,thanks
    – elbarna
    May 18, 2016 at 20:13
  • @schily. Of course it does. It may be implemented as a STREAMS module now, but the line discipline is still there. (see ldterm in the output of strconf on Solaris for instance, run strchg -pu ptem in a terminal emulator or over ssh to see the effect of removing it). May 18, 2016 at 20:28

You must log in to answer this question.

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