2023-05-25 20:50:28 +02:00
|
|
|
---@type wezterm
|
2023-05-18 12:30:46 +02:00
|
|
|
local wezterm = require("wezterm")
|
2023-03-06 11:58:51 +01:00
|
|
|
local M = {}
|
|
|
|
|
2023-05-18 12:30:46 +02:00
|
|
|
---merge two tables, t2 overwriting t1
|
|
|
|
---@param t1 table
|
|
|
|
---@param t2 table
|
|
|
|
---@return table
|
2023-03-06 11:58:51 +01:00
|
|
|
M.tableMerge = function(t1, t2)
|
|
|
|
for k, v in pairs(t2) do
|
|
|
|
if type(v) == "table" then
|
|
|
|
if type(t1[k] or false) == "table" then
|
|
|
|
M.tableMerge(t1[k] or {}, t2[k] or {})
|
|
|
|
else
|
|
|
|
t1[k] = v
|
|
|
|
end
|
|
|
|
else
|
|
|
|
t1[k] = v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return t1
|
|
|
|
end
|
|
|
|
|
2023-05-18 12:30:46 +02:00
|
|
|
---check if a table contains a value
|
|
|
|
---@param t table
|
|
|
|
---@param val any
|
|
|
|
---@return boolean
|
2023-03-06 11:58:51 +01:00
|
|
|
M.tableContains = function(t, val)
|
|
|
|
for _, v in ipairs(t) do
|
|
|
|
if v == val then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2023-05-18 12:30:46 +02:00
|
|
|
---check if we're on Linux
|
|
|
|
---@return boolean
|
|
|
|
M.is_linux = function()
|
|
|
|
return wezterm.target_triple:find("linux") ~= nil
|
|
|
|
end
|
|
|
|
|
|
|
|
---check if we're on macOS
|
|
|
|
---@return boolean
|
|
|
|
M.is_darwin = function()
|
|
|
|
return wezterm.target_triple:find("darwin") ~= nil
|
|
|
|
end
|
|
|
|
|
2023-03-06 11:58:51 +01:00
|
|
|
return M
|