Using XQuartz on MacOS with ksh, this allows me to use Command as Meta. Tested with Emacs and ksh emacs mode. ~/.xmodmap: ! Use command key as meta keycode 63 = Meta_L keycode 71 = Meta_R keycode 66 = Mode_switch keycode 69 = Mode_switch clear mod1 clear mod2 add mod1 = Meta_L Meta_R add mod2 = Mode_switch ~/.Xresources ! Meta characters are converted into a two character sequence ! with the character itself preceded by ESC. xterm*eightBitInput: false On Wed, Feb 5, 2025 at 10:14 PM Nick <atod101101@gmail.com> wrote:
How can I remap these keys so they work as Meta? So emacs mode in the shells with them?
I'm trying to use Meta-b and Meta-f to go backwards and forwards using emacs mode in my shells (tried ksh, zsh, bash). I'm noticing non ASCII characters when I press these Option-b or Option-f.
I noticed in Mac's Terminal.app the option "Use Option as Meta key" checked resolves this issue. It doesn't resolve the issue in my "xterm" session though.
I see some posts referencing setxkbmap and xmodmap (issue is occurring outside of Windows though). I tried xmodmap per below and keys are still having problems.
$ cat ~/.xmodmap
clear Mod1 ! keycodes 66 and 69 are the option/alt keys; assign them as Meta keys keycode 66=Meta_L keycode 69=Meta_R ! now tell X11 that the Meta keys act as the Mod1 (meta) modier key; that is, when they are pressed with KEY, it is the same as hitting M-KEY add Mod1 = Meta_L Meta_R
$ xmodmap ~/.xmodmap
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 118 (X_SetModifierMapping) Value in failed request: 0x17 Serial number of failed request: 14 Current serial number in output stream: 14
The keys output when I press OPTION-f after xmodmap:
$ æ
Pressing left option, shows mapping but it doesn't impact the shell behavior:
$ xev
KeyPress event, serial 34, synthetic NO, window 0xa00001, root 0x141, subw 0x0, time 613883038, (791,832), root:(791,855), state 0x0, keycode 66 (keysym 0xffe7, Meta_L), same_screen YES, XKeysymToKeycode returns keycode: 19 XLookupString gives 0 bytes: XmbLookupString gives 0 bytes: XFilterEvent returns: False