Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
-- https://github.com/wez/wezterm/issues/4533#issuecomment-1874094722
-- is there a better alt?
if vim ~= nil then
return
return
end

local wezterm = require('wezterm')
local wezterm = require("wezterm")
local M = {}

local function trim_quotes(s)
return (s or ""):gsub("^['\"](.-)['\"]$", "%1")
end

---@param var string
---@return boolean
local function is_shell_integ_user_var(var)
local shell_integ_user_vars = {
'WEZTERM_PROG',
'WEZTERM_USER',
'WEZTERM_HOST',
'WEZTERM_IN_TMUX',
}
for _, val in ipairs(shell_integ_user_vars) do
if val == var then
return true
end
end
return false
local shell_integ_user_vars = {
WEZTERM_PROG = true,
WEZTERM_USER = true,
WEZTERM_HOST = true,
WEZTERM_IN_TMUX = true,
}
return shell_integ_user_vars[var] == true
end

---Interpret the Wezterm user var that is passed in and
Expand Down Expand Up @@ -52,8 +51,22 @@ function M.override_user_var(overrides, name, value)
end
overrides[name] = parsed_val
end
end
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge issues showing up :)

return overrides

if name == "font" then
local cleaned = trim_quotes(value)
local success, font_obj = pcall(wezterm.font, cleaned)
if success and font_obj then
if font_obj.font and font_obj.font[1] and font_obj.font[1].family then
font_obj.font[1].family = trim_quotes(font_obj.font[1].family)
end
overrides.font = font_obj
wezterm.log_info("Applied FONT override. Cleaned value:", cleaned)
else
wezterm.log_error("Failed to create font object from sanitized input:", cleaned)
end
return overrides
end
end

return M