Last active
January 8, 2024 09:24
-
-
Save kontza/7ee30f5ed7ae949e90bd03bc0d8bc63d to your computer and use it in GitHub Desktop.
Revisions
-
kontza revised this gist
Jan 8, 2024 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,20 +12,20 @@ wezterm.on("update-status", function(window, pane) 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 -
kontza revised this gist
Jan 8, 2024 . 1 changed file with 25 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,33 +1,33 @@ -- 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) -
kontza revised this gist
Jan 8, 2024 . No changes.There are no files selected for viewing
-
kontza revised this gist
Jan 8, 2024 . No changes.There are no files selected for viewing
-
kontza created this gist
Jan 8, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ -- 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)