-- Hash char is here to make good editors show the color in situ. local host_to_color = { ["main.*p"] = "#660000", ["other.*q"] = "#660066", -- key = a pattern to match a hostname -- value = the color to use as pane background for the hostname } local colored_panes = {} wezterm.on("update-status", function(window, pane) local fg = pane:get_foreground_process_info() or {} if fg.name == "ssh" then for ndx = 2, #fg.argv do for k, v in pairs(host_to_color) do if string.find(fg.argv[ndx], k) then if not colored_panes[pane:pane_id()] then -- print(">>> NEW") pane:inject_output(string.format("\x1b]11;%s\x07", string.sub(v, 2))) colored_panes[pane:pane_id()] = fg.pid end end end end else if colored_panes[pane:pane_id()] then local ssh = wezterm.procinfo.get_info_for_pid(colored_panes[pane:pane_id()]) if not ssh then -- print(">>> CLEARED") colored_panes[pane:pane_id()] = nil pane:inject_output("\x1b]104\x07") end end end end)