Readline is a library that enables Emacs-style shortcuts in the terminal (and other programs), such as Ctrl-A to jump to the start of the line, Meta-W to jump a word, Meta-B to jump a word back, etc. This works on Windows, Linux and Mac.

Now, i18n is where it gets hard, as usual, but only on macOS. The thing is that in the Terminal (or Iterm2) on macOS this does not work out of the box, as you explicitly need to enable the option "Use Opt as a Meta key" in the Terminal settings.

But by doing so, you lose out on the ability to use the Opt/Alt key for its other, much more common uses, as you now cannot type any of the characters needing Alt. In Norwegian layouts you need Alt to type square brackets, tilde and backtics, which is a pretty essential thing for most programmers ...

Now, for me, this led me to a life of dual layouts: switching between US keyboard layout for programming and NO for other stuff. That life is drag. Is there a way of keeping my sanity that enables me to use readline shortcuts in the terminal while keeping my standard Norwegian layout?

enter image description here

Related to this vim question

  • Not necessarily an answer, hence the comment, but... I've got a UK keyboard, and use Esc instead of Opt (like you, I didn't want to "lose" my regular Opt key). Would that be a workable solution for you? (Urgh, forget I said that - it works in emacs but doesn't seem to work at the prompt).
    – John N
    Dec 20, 2016 at 17:29
  • ESC b works for me here :-) And you can always redefine the keybindings for readline.
    – nohillside
    Dec 20, 2016 at 18:12
  • @patrix Only once. While I can hold Alt in while repeatedly pressing B, this does not work with. Esc-B jumps back one word. Esc-B-B jumps back one word and then inserts a B.
    – oligofren
    Dec 21, 2016 at 9:27
  • Ah, right. Alt is a modifier key (like Shift or Control), ESC isn't.
    – nohillside
    Dec 21, 2016 at 9:33


You must log in to answer this question.

Browse other questions tagged .