alacritty: fix toml escape generation

This commit is contained in:
Austin Horstman
2026-06-03 12:52:59 -05:00
parent f384af1bec
commit 4c5c1e8ba1
4 changed files with 29 additions and 2 deletions

View File

@@ -100,8 +100,20 @@ in
_finalAttrs: prevAttrs: {
buildCommand = lib.concatStringsSep "\n" [
prevAttrs.buildCommand
# TODO: why is this needed? Is there a better way to retain escape sequences?
"substituteInPlace $out --replace-quiet '\\\\' '\\'"
# Nix cannot spell TOML escape sequences like "\u001d" directly:
# "\\u001d" is a literal backslash-u string, while fromJSON creates
# a control character and fails for "\u0000". Normalize both TOML
# generator outputs to the Alacritty escape form:
# chars = "\\u001d" -> chars = "\u001d"
# chars = '\u001d' -> chars = "\u001d"
''
sed \
-E \
-e "s/= \"\\\\\\\\u([0-9a-fA-F]{4})\"\$/= \"\\\\u\1\"/" \
-e "s/= '\\\\u([0-9a-fA-F]{4})'\$/= \"\\\\u\1\"/" \
"$out" > "$TMPDIR/alacritty.toml"
cp "$TMPDIR/alacritty.toml" "$out"
''
];
}
);

View File

@@ -15,6 +15,11 @@
mods = "Control";
chars = "\\u000c";
}
{
key = "RBracket";
mods = "Alt";
chars = "\\u001d";
}
];
font =

View File

@@ -9,6 +9,11 @@ chars = "\u000c"
key = "K"
mods = "Control"
[[keyboard.bindings]]
chars = "\u001d"
key = "RBracket"
mods = "Alt"
[window.dimensions]
columns = 200
lines = 3

View File

@@ -13,6 +13,11 @@
mods = "Control";
chars = "\\u000c";
}
{
key = "RBracket";
mods = "Alt";
chars = "\\u001d";
}
];
font = {