Solvedalacritty Support for Alt+key (option as meta)

k-bx
207

I'm actually on macOS and not sure how to correctly describe the issue from technical side.

When in terminal, you can go forward/backward by pressing ctrl+f/ctrl+b and it works in Alacritty, and usually you can jump between words by pressing alt(option)+f/alt(option)+b, but it doesn't work right now.

31 Answers

✔️Accepted Answer

With latest alacritty and tmux, I finally got forward and backward movement with the following:

- { key: F,  mods: Alt,           chars: "\x1bf"                       }
- { key: B,  mods: Alt,           chars: "\x1bb"                       }

Other Answers:

I use alt-hjkl in vim, so I found this limiting as well.

I solved it by adding this to my config:

  - { key: J,        mods: Alt,     chars: "\x1bj"                       }
  - { key: K,        mods: Alt,     chars: "\x1bk"                       }
  - { key: H,        mods: Alt,     chars: "\x1bh"                       }
  - { key: L,        mods: Alt,     chars: "\x1bl"                       }

I guess all these should be added to the default config file.

Didn't really see it mentioned above, and have made it back to this thread a couple of times now, but if anyone wanting to setup meta key bindings, ie. alt + [ALPHA_KEY], as far as I can tell, any of the alpha keys on the keyboard can be used, i.e A through z. All that is required is to do something like,

alacritty.yml

key_bindings:
- { key: [ALPHA_KEY],        mods: Alt,     chars: "\x1b[ALPHA_KEY]"                       }

Substitute [ALPHA_KEY] with a key of A through z on the keyboard.

Ex

key_bindings:
- { key: Q,        mods: Alt,     chars: "\x1bq"                       }

The example above adds a keybinding for alt + q

I hope this note helps future me. 🙋‍♂️

On macOS do this:

  - { key: Up,       mods: Alt,     chars: "\x1b[1;5A"                   }
  - { key: Down,     mods: Alt,     chars: "\x1b[1;5B"                   }
  - { key: Left,     mods: Alt,     chars: "\x1bb"                       }
  - { key: Right,    mods: Alt,     chars: "\x1bf"                       }
  - { key: Key0,     mods: Alt,     chars: "º"                           }
  - { key: Key1,     mods: Alt,     chars: "¡"                           }
  - { key: Key2,     mods: Alt,     chars: "€"                           }
  - { key: Key3,     mods: Alt,     chars: "#"                           }
  - { key: Key4,     mods: Alt,     chars: "¢"                           }
  - { key: Key5,     mods: Alt,     chars: "∞"                           }
  - { key: Key6,     mods: Alt,     chars: "§"                           }
  - { key: Key7,     mods: Alt,     chars: "¶"                           }
  - { key: Key8,     mods: Alt,     chars: "•"                           }
  - { key: Key9,     mods: Alt,     chars: "ª"                           }

In case anyone landing here also wants the forward-delete binding, it's this:

- { key: D,  mods: Alt,           chars: "\x1bd"                       }

More Issues: