0

Context: I use zsh and use vi editing mode. To go up in the history instead of pressing ESC to go to the normal mode and pressing k, I press alt+k which sends the esc character and sends k afterwords (as per my understanding)

Problem: It works fine until I start a ssh session, even after closing the session it doesn't work. Instead, when pressing alt+k it inserts ë character.

Current Understanding: This is something to do with the terminal and not the shell. However, opening a SSH session changes some runtime property of the terminal which I couldn't think of.

st git commit: 63776c0962874dfab135a595a765b4d3b5fbcb65 (current master)

Any idea that helps is greatly appreciated.

PS: I have a very little understanding of how the terminals work internally.

1 Answer 1

1

There is an old way of signalling "meta", which assumes that you are using a 7-bit character set and that it is free to fiddle with the high bits of characters. It doesn't really work well with 8-bit character sets let alone UTF-8, producing characters confusing to the uninitiated as you have seen. Only some terminal emulators support it, including XTerm and Simple Terminal, and it is turned on and off with ECMA-48 vendor-private Set/Reset Mode control sequences, parameter 1034. In terminfo terminology, this is "meta mode".

The program on the remote system that you accessed over SSH turned on "meta mode" for some reason and didn't turn it back off again. You can turn off meta mode by printing the DECRST 1034 control sequence directly with (say) printf:

printf '\e[?%ul' 1034
or with the (terminfo version of the) tput command:

tput rmm

Incidentally: Don't expect the setmetamode command from the kbd package (on operating systems like Debian Linux) to work, as that uses an idiosyncratic way of changing this mode that is specific to the Linux built-in virtual terminal.

1
  • Thank you for the comprehensive explanation! Sending the control sequence worked! Commented Aug 3, 2020 at 14:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.