peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.04k stars 132 forks source link

Alt+Left/Right does not work on macOS #109

Closed AlekSi closed 6 years ago

AlekSi commented 6 years ago

Typical macOS terminal application uses ⌥ (alt) + ←/→ for movements between words. Those combinations send [1;5D for ⌥+← and 1;5C for ⌥+→. And they to do not work with liner.

README mentions Alt-B and Alt-F, but those combinations type and ƒ as expected on macOS.

TERM=xterm-256color
TERM_PROGRAM=iTerm.app
TERM_PROGRAM_VERSION=3.2.0
peterh commented 6 years ago

That's... non-standard, isn't it? My Terminal.app configuration/Keyboard says that ⌥ ← (and →) sends \033b (and \033f). \033[1;5D is ^← (control ←). Either should work, however.

To use Alt- combinations, you have to turn on Terminal.app configuration/Keyboard/Use Option as Meta Key, or you get ∫ and ƒ instead of an actual Alt-key combination sent to the app.

Note that System Preferences/Keyboard/Shortcuts can override any combination (eg. ^← is overridden by default to mean "Mission Control / Move left a space"). You have to turn off any combinations you want passed through to Terminal.

For the most part, if it works in bash, it should work the same way in liner.

AlekSi commented 6 years ago

Hi, sorry for a late response. I was under impression that my configuration was standard… but apparently, it was not, as I discovered after playing with iTerm settings. It works now. Thank you.