Schlez
2024

Fixing Non-working Keybindings in Alacritty 0.13

Teaching Alacritty to handle Command-Shift-] properly.Published .

I migrated to Alacritty from iTerm a long time ago, but for the last few months I've been a WezTerm user, mainly because it intrigued me to get back ligatures and to configure my terminal using Lua. Everything was great: it was pretty snappy, until very recently. I recently upgraded its version and I think there is a performance issue in the latest version, making text rendering slower than it used to.

So I decided to go back to Alacritty, and guess what, it's snappy again. However, my Alacritty build was fairly old: I built it from source when I got my M1 because there was no prebuilt binary that worked on M1 natively without Rosetta. So I downloaded the latest one from Homebrew and ran alacritty upgrade to convert my old configuration from yaml into toml.

Everything was smooth, expect of one issue: Cmd+Shift+[ and Cmd+Shift+] did not send the right commands into tmux. They actually didn't work at all. I wasted an entire day on this issue, and almost decided to give up and use Alt+[ and Alt+] respectively, and then I found this comment on a GitHub issue:

But this, kind of weird, configuration works:

[[keyboard.bindings]]
chars = "\u0000"
key = "@"
mods = "Shift|Command"

where the following ones do not work as expected:

[[keyboard.bindings]]
chars = "\u0000"
key = "2"
mods = "Shift|Command"

[[keyboard.bindings]]
chars = "\u0000"
key = "@"
mods = "Command"

Seems like, now Alcritty requires the shift to be present in the character and modifier as well.

So, in order to map Shift+[key] in Alacritty 0.13, seems that you gotta put Shift as the modifier while also applying the "shift" modifier to the "key" your want to map.

In my case, Cmd+Shift+[ and Cmd+Shift+] meant to map them into Cmd+Shift+{ and Cmd+Shift+} respectively:

[[keyboard.bindings]]
chars = "\u0013p" # <prefix>p
key = "{"
mods = "Command|Shift"

[[keyboard.bindings]]
chars = "\u001Bn" # <prefix>n
key = "}"
mods = "Command|Shift"
Read more