Wezterm


1 Top-level configuration

🎯 wezterm/.wezterm.lua
boilerplate
local cfg = {
  appearance
  keybindings
}

font-by-host

return cfg

2 Appearance

appearance
disable-tab-bar
disable-update-check
disable-BEL-sound
window-padding
window-size
colors
cursor
font

2.1 Disable tab bar

Disable the tab bar because we already get everything we need with tmux windows and panes.

disable-tab-bar
enable_tab_bar = false,

2.2 Disable update check

Disable automated check of newer Wezterm versions because we install Wezterm through a package manager.

disable-update-check
check_for_updates = false,

2.3 Disable BEL ascii sequence (alarm sound)

disable-BEL-sound
audible_bell = "Disabled",

2.4 Window padding

window-padding
window_padding = {
  left = 4,
  right = 0,
  top = 0,
  bottom = 0,
},

2.5 Window size on startup

window-size
initial_cols = 163,
initial_rows = 102,

2.6 Font

Defaults.

font
-- These are also known as OpenType features. The "cv06" here is defined in
-- the font's website in the "Customize" section; it makes the "6" and "9"
-- numerals have a straight, not curved, tail.
harfbuzz_features = {"cv06=1"},
font = wezterm.font_with_fallback {
  "Commit Mono"
},
font_size = 10.5,

Host-specific customisation.

font-by-host
if hostname == 'k0' then
  cfg.font_size = 12
else
  cfg.font = wezterm.font_with_fallback {
    "CommitMono"
  }
  cfg.font_size = 16.0
end

2.7 Colors

The following is taken from https://wezfurlong.org/wezterm/config/appearance.html.

colors
colors = {
  -- The default text color
  foreground = '#e5e7ea',
  -- The default background color
  background = '#343c48',

  -- Overrides the cell background color when the current cell is occupied by the
  -- cursor and the cursor style is set to Block
  cursor_bg = '#ffffff',
  -- Overrides the text color when the current cell is occupied by the cursor
  cursor_fg = '#000000',
  -- Specifies the border color of the cursor when the cursor style is set to Block,
  -- or the color of the vertical or horizontal bar when the cursor style is set to
  -- Bar or Underline.
  cursor_border = '#52ad70',

  -- the foreground color of selected text
  selection_fg = '#000000',
  -- the background color of selected text
  selection_bg = '#fffacd',

  ansi = {
    '#22222f',
    '#e49f9f',
    '#91e380',
    '#eae47c',
    '#7cacd3',
    '#df9494',
    '#8cdbd8',
    '#e5e7ea',
  },
  brights = {
    '#99999f',
    '#e5bfbf',
    '#afe0a1',
    '#f2fb9e',
    '#95add1',
    '#f2b0b0',
    '#b4f0f0',
    '#ffffff',
  },

  -- Since: 20220319-142410-0fcdea07
  -- When the IME, a dead key or a leader key are being processed and are effectively
  -- holding input pending the result of input composition, change the cursor
  -- to this color to give a visual cue about the compose state.
  compose_cursor = 'orange',

  -- Colors for copy_mode and quick_select
  -- available since: 20220807-113146-c2fee766
  -- In copy_mode, the color of the active text is:
  -- 1. copy_mode_active_highlight_* if additional text was selected using the mouse
  -- 2. selection_* otherwise
  copy_mode_active_highlight_bg = { Color = '#000000' },
  -- use `AnsiColor` to specify one of the ansi color palette values
  -- (index 0-15) using one of the names "Black", "Maroon", "Green",
  --  "Olive", "Navy", "Purple", "Teal", "Silver", "Grey", "Red", "Lime",
  -- "Yellow", "Blue", "Fuchsia", "Aqua" or "White".
  copy_mode_active_highlight_fg = { AnsiColor = 'Black' },
  copy_mode_inactive_highlight_bg = { Color = '#52ad70' },
  copy_mode_inactive_highlight_fg = { AnsiColor = 'White' },

  quick_select_label_bg = { Color = 'peru' },
  quick_select_label_fg = { Color = '#ffffff' },
  quick_select_match_bg = { AnsiColor = 'Navy' },
  quick_select_match_fg = { Color = '#ffffff' },
},

2.8 Cursor

cursor
cursor_blink_rate = 0,

2.9 (Disabled) Help poorly-written TUI programs flicker less

See https://github.com/zed-industries/wezterm/commit/7caaf136e49c7f1785be69403c54a734a6ce6f27.

This doesn't appear to help terminal emacs much (flicker caused by using a different background color than the one used by default in the terminal).

flicker_reduction
mux_output_parser_coalesce_delay_ms = 100,

3 Keybindings

keybindings
keys = {
  clear-specific-default-bindings
  basic-bindings
  csi-u-mode
},
clear-specific-default-bindings
{ key = "t", mods = "SUPER", action = act.DisableDefaultAssignment },
basic-bindings
{ key = "y", mods = "SUPER", action = act.ActivateCopyMode },
{ key = "y", mods = "SUPER|CTRL", action = act.QuickSelect },
open-url

3.1 Open URL

Taken from https://wezfurlong.org/wezterm/config/lua/keyassignment/QuickSelectArgs.html as that appears to be the only upstream page detailing how to quickly open a URL using the keyboard. It appears to be first mentioned in https://github.com/wez/wezterm/issues/1362#issuecomment-1000457693.

open-url
{ key = "y", mods = "SUPER|SHIFT",
  action = wezterm.action.QuickSelectArgs {
    label = "open url",
    patterns = {
      "https?://\\S+",
    },
    action = wezterm.action_callback(function(window, pane)
      local url = window:get_selection_text_for_pane(pane)
      -- Remove any suspicious-looking trailing punctuation character from the
      -- URL, because 99.99% of the time, this is just carried over from the
      -- surrounding text and is not actually part of the URL. We have to escape
      -- some characters with a percent sign (%) because they are considered
      -- magic characters in Lua.
      local suspicious_chars = {
        {char=")", is_magic=true},
        {char="]", is_magic=true},
        {char="}", is_magic=false},
        {char=",", is_magic=false},
        {char=".", is_magic=true},
        {char=":", is_magic=false},
        {char=";", is_magic=false}}
      for k, v in ipairs(suspicious_chars) do
        if string.sub(url, -1) == v.char then
          wezterm.log_info("deleting trailing character " .. v.char .. " from url")
          if v.is_magic then
            url = string.gsub(url, "%" .. v.char .. "$", "")
          else
            url = string.gsub(url, v.char .. "$", "")
          end
          break
        end
      end
      wezterm.log_info("opening: " .. url)
      wezterm.open_with(url)
    end),
  },
},

3.2 CSI-u mode

Distinguish between problematic keys (such as C-<key> and C-S-<key>) via manual CSI u support. See https://iterm2.com/documentation-csiu.html for a background around CSI u aka libtickit.

The list here is originally drawn from https://github.com/alexherbo2/alacritty-extended-keys/blob/bc08749ae8fd9f8e00d0c93f96d5c67c244c6480/keys.yml#L16.

3.2.1 M-{a-z}

We cannot use CSI u mode bindings for plain M-{a-z} combinations because then we break legacy programs (e.g., Zsh). The same thing goes for M-{A-Z}, C-{a-z}, and C-M-{a-z} combinations. By default these keys should already be "bound" this way in Wezterm, but we list them here for sake of completeness.

csi-u-mode-M-a-z
bind("a", M, "\x1b[97;3u"),
bind("b", M, "\x1b[98;3u"),
bind("c", M, "\x1b[99;3u"),
bind("d", M, "\x1b[100;3u"),
bind("e", M, "\x1b[101;3u"),
bind("f", M, "\x1b[102;3u"),
bind("g", M, "\x1b[103;3u"),
bind("h", M, "\x1b[104;3u"),
bind("i", M, "\x1b[105;3u"),
bind("j", M, "\x1b[106;3u"),
bind("k", M, "\x1b[107;3u"),
bind("l", M, "\x1b[108;3u"),
bind("m", M, "\x1b[109;3u"),
bind("n", M, "\x1b[110;3u"),
bind("o", M, "\x1b[111;3u"),
bind("p", M, "\x1b[112;3u"),
bind("q", M, "\x1b[113;3u"),
bind("r", M, "\x1b[114;3u"),
bind("s", M, "\x1b[115;3u"),
bind("t", M, "\x1b[116;3u"),
bind("u", M, "\x1b[117;3u"),
bind("v", M, "\x1b[118;3u"),
bind("w", M, "\x1b[119;3u"),
bind("x", M, "\x1b[120;3u"),
bind("y", M, "\x1b[121;3u"),
bind("z", M, "\x1b[122;3u"),

3.2.2 M-S-{a-z}

csi-u-mode-M-S-a-z
bind("a", MS, "\x1b[97;4u"),
bind("b", MS, "\x1b[98;4u"),
bind("c", MS, "\x1b[99;4u"),
bind("d", MS, "\x1b[100;4u"),
bind("e", MS, "\x1b[101;4u"),
bind("f", MS, "\x1b[102;4u"),
bind("g", MS, "\x1b[103;4u"),
bind("h", MS, "\x1b[104;4u"),
bind("i", MS, "\x1b[105;4u"),
bind("j", MS, "\x1b[106;4u"),
bind("k", MS, "\x1b[107;4u"),
bind("l", MS, "\x1b[108;4u"),
bind("m", MS, "\x1b[109;4u"),
bind("n", MS, "\x1b[110;4u"),
bind("o", MS, "\x1b[111;4u"),
bind("p", MS, "\x1b[112;4u"),
bind("q", MS, "\x1b[113;4u"),
bind("r", MS, "\x1b[114;4u"),
bind("s", MS, "\x1b[115;4u"),
bind("t", MS, "\x1b[116;4u"),
bind("u", MS, "\x1b[117;4u"),
bind("v", MS, "\x1b[118;4u"),
bind("w", MS, "\x1b[119;4u"),
bind("x", MS, "\x1b[120;4u"),
bind("y", MS, "\x1b[121;4u"),
bind("z", MS, "\x1b[122;4u"),

3.2.3 C-{a-z}

csi-u-mode-C-a-z
bind("a", C, "\x1b[97;5u"),
bind("b", C, "\x1b[98;5u"),
bind("c", C, "\x1b[99;5u"),
bind("d", C, "\x1b[100;5u"),
bind("e", C, "\x1b[101;5u"),
bind("f", C, "\x1b[102;5u"),
bind("g", C, "\x1b[103;5u"),
bind("h", C, "\x1b[104;5u"),
bind("i", C, "\x1b[105;5u"),
bind("j", C, "\x1b[106;5u"),
bind("k", C, "\x1b[107;5u"),
bind("l", C, "\x1b[108;5u"),
bind("m", C, "\x1b[109;5u"),
bind("n", C, "\x1b[110;5u"),
bind("o", C, "\x1b[111;5u"),
bind("p", C, "\x1b[112;5u"),
bind("q", C, "\x1b[113;5u"),
bind("r", C, "\x1b[114;5u"),
bind("s", C, "\x1b[115;5u"),
bind("t", C, "\x1b[116;5u"),
bind("u", C, "\x1b[117;5u"),
bind("v", C, "\x1b[118;5u"),
bind("w", C, "\x1b[119;5u"),
bind("x", C, "\x1b[120;5u"),
bind("y", C, "\x1b[121;5u"),
bind("z", C, "\x1b[122;5u"),

3.2.4 C-S-{a-z}

csi-u-mode-C-S-a-z
bind("a", CS, "\x1b[97;6u"),
bind("b", CS, "\x1b[98;6u"),
bind("c", CS, "\x1b[99;6u"),
bind("d", CS, "\x1b[100;6u"),
bind("e", CS, "\x1b[101;6u"),
bind("f", CS, "\x1b[102;6u"),
bind("g", CS, "\x1b[103;6u"),
bind("h", CS, "\x1b[104;6u"),
bind("i", CS, "\x1b[105;6u"),
bind("j", CS, "\x1b[106;6u"),
bind("k", CS, "\x1b[107;6u"),
bind("l", CS, "\x1b[108;6u"),
bind("m", CS, "\x1b[109;6u"),
bind("n", CS, "\x1b[110;6u"),
bind("o", CS, "\x1b[111;6u"),
bind("p", CS, "\x1b[112;6u"),
bind("q", CS, "\x1b[113;6u"),
bind("r", CS, "\x1b[114;6u"),
bind("s", CS, "\x1b[115;6u"),
bind("t", CS, "\x1b[116;6u"),
bind("u", CS, "\x1b[117;6u"),
bind("v", CS, "\x1b[118;6u"),
bind("w", CS, "\x1b[119;6u"),
bind("x", CS, "\x1b[120;6u"),
bind("y", CS, "\x1b[121;6u"),
bind("z", CS, "\x1b[122;6u"),

3.2.5 C-M-{a-z}

Alt is interpreted as a leading ESC, and the Control modifier shifts the ASCII codepoint by -64. This is why, e.g., 'A' (ASCII codepoint 65) becomes codepoint 1.

csi-u-mode-C-M-a-z
bind("a", CM, "\x1b[97;7u"),
bind("b", CM, "\x1b[98;7u"),
bind("c", CM, "\x1b[99;7u"),
bind("d", CM, "\x1b[100;7u"),
bind("e", CM, "\x1b[101;7u"),
bind("f", CM, "\x1b[102;7u"),
bind("g", CM, "\x1b[103;7u"),
bind("h", CM, "\x1b[104;7u"),
bind("i", CM, "\x1b[105;7u"),
bind("j", CM, "\x1b[106;7u"),
bind("k", CM, "\x1b[107;7u"),
bind("l", CM, "\x1b[108;7u"),
bind("m", CM, "\x1b[109;7u"),
bind("n", CM, "\x1b[110;7u"),
bind("o", CM, "\x1b[111;7u"),
bind("p", CM, "\x1b[112;7u"),
bind("q", CM, "\x1b[113;7u"),
bind("r", CM, "\x1b[114;7u"),
bind("s", CM, "\x1b[115;7u"),
bind("t", CM, "\x1b[116;7u"),
bind("u", CM, "\x1b[117;7u"),
bind("v", CM, "\x1b[118;7u"),
bind("w", CM, "\x1b[119;7u"),
bind("x", CM, "\x1b[120;7u"),
bind("y", CM, "\x1b[121;7u"),
bind("z", CM, "\x1b[122;7u"),

3.2.6 C-M-S-{a-z}

Note that as a convention we reserve C-M-S- (as well as C-M-) to tmux keybindings. So these bindings rarely get used by other CLI programs that we use (because we don't like having the same bindings do different things based on whether we're running inside tmux or not).

csi-u-mode-C-M-S-a-z
bind("a", CMS, "\x1b[97;8u"),
bind("b", CMS, "\x1b[98;8u"),
bind("c", CMS, "\x1b[99;8u"),
bind("d", CMS, "\x1b[100;8u"),
bind("e", CMS, "\x1b[101;8u"),
bind("f", CMS, "\x1b[102;8u"),
bind("g", CMS, "\x1b[103;8u"),
bind("h", CMS, "\x1b[104;8u"),
bind("i", CMS, "\x1b[105;8u"),
bind("j", CMS, "\x1b[106;8u"),
bind("k", CMS, "\x1b[107;8u"),
bind("l", CMS, "\x1b[108;8u"),
bind("m", CMS, "\x1b[109;8u"),
bind("n", CMS, "\x1b[110;8u"),
bind("o", CMS, "\x1b[111;8u"),
bind("p", CMS, "\x1b[112;8u"),
bind("q", CMS, "\x1b[113;8u"),
bind("r", CMS, "\x1b[114;8u"),
bind("s", CMS, "\x1b[115;8u"),
bind("t", CMS, "\x1b[116;8u"),
bind("u", CMS, "\x1b[117;8u"),
bind("v", CMS, "\x1b[118;8u"),
bind("w", CMS, "\x1b[119;8u"),
bind("x", CMS, "\x1b[120;8u"),
bind("y", CMS, "\x1b[121;8u"),
bind("z", CMS, "\x1b[122;8u"),

3.2.7 Exotic keybindings

(Normally) dead keys. Bring them back to life with CSI u sequences!

Note that these bindings are limited to what tmux is able to understand. For example, we cannot send \x1b[34;5u (C-") because tmux is unable to parse it. So we instead send \x1b[39;6u (C-S-') instead.

For more information about the underlying decimal codes used here, see man ascii in Linux or Mac.

csi-u-mode-exotic
bind("!", CS, "\x1b[33;5u"), -- C-!
bind('"', CS, "\x1b[39;6u"), -- C-" (C-S-')
bind("#", CS, "\x1b[35;5u"), -- C-#
bind("$", CS, "\x1b[52;6u"), -- C-$ (C-S-4)
bind("%", CS, "\x1b[53;6u"), -- C-% (C-S-5)
bind("&", CS, "\x1b[55;6u"), -- C-& (C-S-7)
bind("'", C,  "\x1b[39;5u"), -- C-'
bind("(", CS, "\x1b[40;5u"), -- C-(
bind(")", CS, "\x1b[41;5u"), -- C-)
bind("*", CS, "\x1b[56;6u"), -- C-* (C-S-8)
bind("+", CS, "\x1b[43;5u"), -- C-+
bind(",", C,  "\x1b[44;5u"), -- C-,
bind("-", C,  "\x1b[45;5u"), -- C--
bind(".", C,  "\x1b[46;5u"), -- C-.
bind("/", C,  "\x1b[47;5u"), -- C-/
bind("0", C,  "\x1b[48;5u"), -- C-0
-- On Mac, we have to manually disable the C-1 and C-2 bindings which are by
-- default bound to switch to Desktops 1 and 2.
bind("1", C,  "\x1b[49;5u"), -- C-1
bind("2", C,  "\x1b[50;5u"), -- C-2
bind("3", C,  "\x1b[51;5u"), -- C-3
bind("4", C,  "\x1b[52;5u"), -- C-4
bind("5", C,  "\x1b[53;5u"), -- C-5
bind("6", C,  "\x1b[54;5u"), -- C-6
bind("7", C,  "\x1b[55;5u"), -- C-7
bind("8", C,  "\x1b[56;5u"), -- C-8
bind("9", C,  "\x1b[57;5u"), -- C-9
bind(":", CS, "\x1b[58;5u"), -- C-:
bind(";", C,  "\x1b[59;5u"), -- C-;
bind("<", CS, "\x1b[60;5u"), -- C-<
bind("=", C,  "\x1b[61;5u"), -- C-=
bind(">", CS, "\x1b[62;5u"), -- C->
bind("?", CS, "\x1b[47;6u"), -- C-? (C-S-/)
-- C-@ (that is, C-S-2) by default sends a literal NUL character. This is pretty
-- much useless so we create a separate mapping here.
bind("@", CS, "\x1b[64;5u"), -- C-@ (C-S-2)

-- C-A to C-Z (codepoints 65-90) are handled already above.

-- C-\ by default sends 0x1c, which is the FS (file separator) key. See
-- https://en.wikipedia.org/wiki/Control-%5C. Most UNIX programs interpret this
-- as a SIGQUIT, but in Emacs it's the default keystroke mapping for
-- toggle-input-method.
--
-- Anyway, there is almost never a need to send SIGQUIT to any program these
-- days. The C-], C-^, and C-_ bindings send the group separator, record
-- separator, and unit separator codepoints, which aren't really used by most
-- CLI programs, so we remap them.
bind("\\", C, "\x1b[92;5u"), -- C-\
bind("]", C,  "\x1b[93;5u"), -- C-]
bind("^", CS, "\x1b[94;5u"), -- C-^
bind("_", CS, "\x1b[95;5u"), -- C-_
bind("`", C,  "\x1b[96;5u"), -- C-`
bind("|", CS, "\x1b[92;6u"), -- C-| (C-S-\)
bind("}", CS, "\x1b[93;6u"), -- C-} (C-S-])
bind("~", CS, "\x1b[96;6u"), -- C-~ (C-S-`)

csi-u-mode-exotic-lbracket
csi-u-mode-exotic-escape
csi-u-mode-exotic-tab
csi-u-mode-exotic-backspace
csi-u-mode-exotic-enter
csi-u-mode-exotic-space
3.2.7.1 Left bracket

Don't make C-[ map to ESC, because we never use it that way. Again, we rebind this from tmux to be the CSI u encoded version. (This is the same method we use to map C-i (to be different from TAB)).

For simplicity we handle all variations of the problematic [ key here (usually conflicts with Escape).

csi-u-mode-exotic-lbracket
bind("[", M,   "\x1b[91;3u"), -- M-[
bind("[", MS,  "\x1b[91;4u"), -- M-S-[ (M-{)
bind("[", C,   "\x1b[91;5u"), -- C-[
bind("[", CS,  "\x1b[91;6u"), -- C-S-[ (C-{)
bind("[", CM,  "\x1b[91;7u"), -- C-M-[
bind("[", CMS, "\x1b[91;8u"), -- C-M-S-[ (C-M-{)
3.2.7.2 Escape

Disambiguate various ESC + modifier key chords.

csi-u-mode-exotic-escape
bind("Escape", S,   "\x1b[27;2u"), -- S-ESC
bind("Escape", M,   "\x1b[27;3u"), -- M-ESC
bind("Escape", MS,  "\x1b[27;4u"), -- M-S-ESC
bind("Escape", C,   "\x1b[27;5u"), -- C-ESC
bind("Escape", CS,  "\x1b[27;6u"), -- C-S-ESC
bind("Escape", CM,  "\x1b[27;7u"), -- C-M-ESC
bind("Escape", CMS, "\x1b[27;8u"), -- C-M-S-ESC
3.2.7.3 Tab

Don't map S-TAB because most terminals (including Alacritty) send \x1b[Z for this, and many existing programs interpret this as S-TAB. In Emacs it interprets it as <backtab>.

M-TAB is \x1b\x09 (ESC followed by TAB), so don't map this either.

For some reason C-S-TAB sends \x19 (EM (end of medium)), which can already be sent via C-y, so remap it here.

csi-u-mode-exotic-tab
bind("Tab", MS,  "\x1b[9;4u"), -- M-S-TAB
bind("Tab", C,   "\x1b[9;5u"), -- C-TAB
bind("Tab", CS,  "\x1b[9;6u"), -- C-S-TAB
bind("Tab", CM,  "\x1b[9;7u"), -- C-M-TAB
bind("Tab", CMS, "\x1b[9;8u"), -- C-M-S-TAB
3.2.7.4 Backspace
csi-u-mode-exotic-backspace
bind("Backspace", S,   "\x1b[127;2u"), -- S-Backspace
bind("Backspace", M,   "\x1b[127;3u"), -- M-Backspace
bind("Backspace", MS,  "\x1b[127;4u"), -- M-S-Backspace
bind("Backspace", C,   "\x1b[127;5u"), -- C-Backspace
bind("Backspace", CS,  "\x1b[127;6u"), -- C-S-Backspace
bind("Backspace", CM,  "\x1b[127;7u"), -- C-M-Backspace
bind("Backspace", CMS, "\x1b[127;8u"), -- C-M-S-Backspace
3.2.7.5 Enter

Because tmux has another bug where Enter (0x0a, or decimal codepoint 10) is indistinguishable from C-j, even if we use CSI u encodings, we have to use 0x0d instead (decimal codepoint 13 or \r).

For S-Enter we use the same trick of sending F12 (\x1b[24~) first to enter our tmux's virt key table as we've done elsewhere in this config.

csi-u-mode-exotic-enter
bind("Enter", S,   "\x1b[13;2u"), -- S-Enter
bind("Enter", M,   "\x1b[13;3u"), -- M-Enter
bind("Enter", MS,  "\x1b[13;4u"), -- M-S-Enter
bind("Enter", C,   "\x1b[13;5u"), -- C-Enter
bind("Enter", CS,  "\x1b[13;6u"), -- C-S-Enter
bind("Enter", CM,  "\x1b[13;7u"), -- C-M-Enter
bind("Enter", CMS, "\x1b[13;8u"), -- C-M-S-Enter
3.2.7.6 Space

C-Space sends the NUL byte (\x00) in Alacritty, but in tmux it just sends the regular Space character. So it looks like there is no consensus in terminal programs, so we rebind it here.

S-Space is useful to just send the Space character, because we can type capital letters with spaces in-between them without having to lift the Shift key, so we don't rebind it.

csi-u-mode-exotic-space
bind("Space", M,   "\x1b[32;3u"), -- M-Space
bind("Space", MS,  "\x1b[32;4u"), -- M-S-Space
bind("Space", C,   "\x1b[32;5u"), -- C-Space
bind("Space", CS,  "\x1b[32;6u"), -- C-S-Space
bind("Space", CM,  "\x1b[32;7u"), -- C-M-Space
bind("Space", CMS, "\x1b[32;8u"), -- C-M-S-Space

3.2.8 Exotic keybindings (M)

csi-u-mode-exotic-M
bind("!", MS, "\x1b[33;3u"), -- M-!
bind('"', MS, "\x1b[39;4u"), -- M-" (M-S-')
bind("#", MS, "\x1b[35;3u"), -- M-#
bind("$", MS, "\x1b[52;4u"), -- M-$ (M-S-4)
bind("%", MS, "\x1b[53;4u"), -- M-% (M-S-5)
bind("&", MS, "\x1b[55;4u"), -- M-& (M-S-7)
bind("'", M,  "\x1b[39;3u"), -- M-'
bind("(", MS, "\x1b[40;3u"), -- M-(
bind(")", MS, "\x1b[41;3u"), -- M-)
bind("*", MS, "\x1b[56;4u"), -- M-* (M-S-8)
bind("+", MS, "\x1b[43;3u"), -- M-+
bind(",", M,  "\x1b[44;3u"), -- M-,
bind("-", M,  "\x1b[45;3u"), -- M--
bind(".", M,  "\x1b[46;3u"), -- M-.
bind("/", M,  "\x1b[47;3u"), -- M-/
bind("0", M,  "\x1b[48;3u"), -- M-0
bind("1", M,  "\x1b[49;3u"), -- M-1
bind("2", M,  "\x1b[50;3u"), -- M-2
bind("3", M,  "\x1b[51;3u"), -- M-3
bind("4", M,  "\x1b[52;3u"), -- M-4
bind("5", M,  "\x1b[53;3u"), -- M-4
bind("6", M,  "\x1b[54;3u"), -- M-6
bind("7", M,  "\x1b[55;3u"), -- M-7
bind("8", M,  "\x1b[56;3u"), -- M-8
bind("9", M,  "\x1b[57;3u"), -- M-9
bind(":", MS, "\x1b[58;3u"), -- M-:
bind(";", M,  "\x1b[59;3u"), -- M-;
bind("<", MS, "\x1b[60;3u"), -- M-<
bind("=", M,  "\x1b[61;3u"), -- M-=
bind(">", MS, "\x1b[62;3u"), -- M->
bind("?", MS, "\x1b[47;4u"), -- M-? (M-S-/)
bind("@", MS, "\x1b[64;3u"), -- M-@
-- Codes 65-90 are A-Z.
bind("\\", M, "\x1b[92;3u"), -- M-\
bind("]", M,  "\x1b[93;3u"), -- M-]
bind("^", MS, "\x1b[94;3u"), -- M-^
bind("_", MS, "\x1b[95;3u"), -- M-_
bind("`", M,  "\x1b[96;3u"), -- M-`
-- Codes 97-122 are a-z.
bind("|", MS, "\x1b[92;4u"), -- M-| (M-S-\)
bind("}", MS, "\x1b[93;4u"), -- M-} (M-S-])
bind("~", MS, "\x1b[96;4u"), -- M-~ (M-S-`)

3.2.9 Exotic keybindings (C-M)

csi-u-mode-exotic-C-M
bind("!", CMS, "\x1b[33;7u"), -- C-M-!
bind('"', CMS, "\x1b[39;8u"), -- C-M-" (C-M-S-')
bind("#", CMS, "\x1b[35;7u"), -- C-M-#
bind("$", CMS, "\x1b[52;8u"), -- C-M-$ (C-M-S-4)
bind("%", CMS, "\x1b[53;8u"), -- C-M-% (C-M-S-5)
bind("&", CMS, "\x1b[55;8u"), -- C-M-& (C-M-S-7)
bind("'", CM,  "\x1b[39;7u"), -- C-M-'
bind("(", CMS, "\x1b[40;7u"), -- C-M-(
bind(")", CMS, "\x1b[41;7u"), -- C-M-)
bind("*", CMS, "\x1b[56;8u"), -- C-M-* (C-M-S-8)
bind("+", CMS, "\x1b[43;7u"), -- C-M-+
bind(",", CM,  "\x1b[44;7u"), -- C-M-,
bind("-", CM,  "\x1b[45;7u"), -- C-M--
bind(".", CM,  "\x1b[46;7u"), -- C-M-.
bind("/", CM,  "\x1b[47;7u"), -- C-M-/
bind("0", CM,  "\x1b[48;7u"), -- C-M-0
bind("1", CM,  "\x1b[49;7u"), -- C-M-1
bind("2", CM,  "\x1b[50;7u"), -- C-M-2
bind("3", CM,  "\x1b[51;7u"), -- C-M-3
bind("4", CM,  "\x1b[52;7u"), -- C-M-4
bind("5", CM,  "\x1b[53;7u"), -- C-M-4
bind("6", CM,  "\x1b[54;7u"), -- C-M-6
bind("7", CM,  "\x1b[55;7u"), -- C-M-7
bind("8", CM,  "\x1b[56;7u"), -- C-M-8
bind("9", CM,  "\x1b[57;7u"), -- C-M-9
bind(":", CMS, "\x1b[58;7u"), -- C-M-:
bind(";", CM,  "\x1b[59;7u"), -- C-M-;
bind("<", CMS, "\x1b[60;7u"), -- C-M-<
bind("=", CM,  "\x1b[61;7u"), -- C-M-=
bind(">", CMS, "\x1b[62;7u"), -- C-M->
bind("?", CMS, "\x1b[47;8u"), -- C-M-? (C-M-S-/)
bind("@", CMS, "\x1b[64;7u"), -- C-M-@
bind("\\", CM, "\x1b[92;7u"), -- C-M-\
bind("]", CM,  "\x1b[93;7u"), -- C-M-]
bind("^", CMS, "\x1b[94;7u"), -- C-M-^
bind("_", CMS, "\x1b[95;7u"), -- C-M-_
bind("`", CM,  "\x1b[96;7u"), -- C-M-`
bind("|", CMS, "\x1b[92;8u"), -- C-M-| (C-M-S-\)
bind("}", CMS, "\x1b[93;8u"), -- C-M-} (C-M-S-])
bind("~", CMS, "\x1b[96;8u"), -- C-M-~ (C-M-S-`)

4 Boilerplate

boilerplate
local wezterm = require 'wezterm'
local act = wezterm.action
local M = "ALT"
local MS = "ALT|SHIFT"
local C = "CTRL"
local CS = "CTRL|SHIFT"
local CM = "CTRL|ALT"
local CMS = "CTRL|ALT|SHIFT"
local CS = "CTRL|SHIFT"
local S = "SHIFT"
local hostname = wezterm.hostname()

local bind = function(key, mods, sequence)
  return {
    key = key,
    mods = mods,
    action = wezterm.action.SendString(sequence)
  }
end

Page metrics

Tangled files (1)

  1. wezterm/.wezterm.lua

Named cells (32)

  1. appearance
  2. basic-bindings
  3. boilerplate
  4. clear-specific-default-bindings
  5. colors
  6. csi-u-mode
  7. csi-u-mode-C-M-S-a-z
  8. csi-u-mode-C-M-a-z
  9. csi-u-mode-C-S-a-z
  10. csi-u-mode-C-a-z
  11. csi-u-mode-M-S-a-z
  12. csi-u-mode-M-a-z
  13. csi-u-mode-exotic
  14. csi-u-mode-exotic-C-M
  15. csi-u-mode-exotic-M
  16. csi-u-mode-exotic-backspace
  17. csi-u-mode-exotic-enter
  18. csi-u-mode-exotic-escape
  19. csi-u-mode-exotic-lbracket
  20. csi-u-mode-exotic-space
  21. csi-u-mode-exotic-tab
  22. cursor
  23. disable-BEL-sound
  24. disable-tab-bar
  25. disable-update-check
  26. flicker_reduction
  27. font
  28. font-by-host
  29. keybindings
  30. open-url
  31. window-padding
  32. window-size