WezTerm
Click any .md path in WezTerm to open it in Bareview — plain click is WezTerm's default. Inside tmux, hold SHIFT while clicking so WezTerm sees the event instead of tmux.
Wire it up manually
local function bareview_trim(s)
return (s:gsub("^%s+", ""):gsub("%s+$", ""))
end
local function bareview_percent_decode(s)
return (s:gsub("%%(%x%x)", function(hex)
return string.char(tonumber(hex, 16))
end))
end
local function bareview_cwd_from_wezterm(pane)
local cwd_uri = pane:get_current_working_dir()
if not cwd_uri then return nil end
if cwd_uri.file_path then return cwd_uri.file_path end
local cwd = tostring(cwd_uri):gsub("^file://[^/]*", "")
cwd = bareview_percent_decode(cwd)
return cwd ~= "" and cwd or nil
end
local function bareview_tmux_client_pid(pane)
local ok, info = pcall(function() return pane:get_foreground_process_info() end)
if not ok or not info then return nil end
local name = info.name or ""
local executable = info.executable or ""
if name == "tmux" or executable:match("/tmux$") then
return tostring(info.pid)
end
return nil
end
local function bareview_cwd_from_tmux(pane)
local client_pid = bareview_tmux_client_pid(pane)
if not client_pid then return nil end
local candidates = { "/opt/homebrew/bin/tmux", "/usr/local/bin/tmux", "/usr/bin/tmux", "tmux" }
for _, tmux in ipairs(candidates) do
local spawn_ok, ok, stdout = pcall(function()
return wezterm.run_child_process({ tmux, "display-message", "-c", client_pid, "-p", "#{pane_current_path}" })
end)
if spawn_ok and ok then
local cwd = bareview_trim(stdout or "")
if cwd ~= "" then return cwd end
end
end
return nil
end
local function bareview_pane_cwd(pane)
return bareview_cwd_from_tmux(pane) or bareview_cwd_from_wezterm(pane)
end
local function bareview_resolve_path(pane, path)
path = path:gsub("\\ ", " ")
if path:sub(1, 2) == "~/" then return (os.getenv("HOME") or "") .. path:sub(2) end
if path:sub(1, 1) == "/" then return path end
local cwd = bareview_pane_cwd(pane) or "."
return cwd .. "/" .. path
end
config.hyperlink_rules = config.hyperlink_rules or wezterm.default_hyperlink_rules()
table.insert(config.hyperlink_rules, {
regex = [[(?:~/|/|\./|\.\./)?[A-Za-z0-9_.-](?:[A-Za-z0-9_./~-]|\\ )*\.(?:md|markdown)]],
format = "bareview-md://open/$0",
})
wezterm.on("open-uri", function(window, pane, uri)
local path = uri:match("^bareview%-md://open/(.+)$")
if not path then return true end
local resolved = bareview_resolve_path(pane, path)
wezterm.background_child_process({ "/usr/bin/open", "-a", "Bareview", resolved })
return false
end)