2023-02-14 12:01:37 +00:00
|
|
|
local wezterm = require("wezterm")
|
|
|
|
|
2023-02-14 18:00:43 +00:00
|
|
|
-- Equivalent to POSIX basename(3)
|
|
|
|
-- Given "/foo/bar" returns "bar"
|
|
|
|
-- Given "c:\\foo\\bar" returns "bar"
|
|
|
|
function basename(s)
|
|
|
|
return string.gsub(s, "(.*[/\\])(.*)", "%2")
|
|
|
|
end
|
|
|
|
|
2023-02-14 12:01:37 +00:00
|
|
|
wezterm.on("update-right-status", function(window, pane)
|
2023-02-14 18:00:43 +00:00
|
|
|
local scheme = wezterm.color.get_builtin_schemes()["kanagawabones"]
|
2023-02-14 12:01:37 +00:00
|
|
|
-- Each element holds the text for a cell in a "powerline" style << fade
|
|
|
|
local cells = {}
|
|
|
|
|
2023-02-14 18:00:43 +00:00
|
|
|
-- Show current active key table
|
|
|
|
local name = window:active_key_table()
|
|
|
|
if name then
|
|
|
|
name = "TABLE: " .. name
|
|
|
|
table.insert(cells, name)
|
|
|
|
end
|
|
|
|
|
2023-02-14 12:01:37 +00:00
|
|
|
-- I like my date/time in this style: "Wed Mar 3 08:14"
|
2023-02-14 18:00:43 +00:00
|
|
|
-- local date = wezterm.strftime("%a %b %-d %H:%M")
|
|
|
|
local date = wezterm.strftime("%Y-%m-%d")
|
2023-02-14 12:01:37 +00:00
|
|
|
table.insert(cells, date)
|
2023-02-14 18:00:43 +00:00
|
|
|
local time = wezterm.strftime("%H:%M")
|
|
|
|
table.insert(cells, time)
|
2023-02-14 12:01:37 +00:00
|
|
|
|
2023-02-14 15:11:10 +00:00
|
|
|
-- Get current hostname to track which device I'm on
|
|
|
|
table.insert(cells, wezterm.hostname())
|
|
|
|
|
2023-02-14 12:01:37 +00:00
|
|
|
-- An entry for each battery (typically 0 or 1 battery)
|
|
|
|
for _, b in ipairs(wezterm.battery_info()) do
|
|
|
|
table.insert(cells, string.format("%.0f%%", b.state_of_charge * 100))
|
|
|
|
end
|
|
|
|
|
|
|
|
-- The powerline < symbol
|
|
|
|
local LEFT_ARROW = utf8.char(0xe0b3)
|
|
|
|
-- The filled in variant of the < symbol
|
|
|
|
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
|
|
|
|
|
2023-02-14 18:00:43 +00:00
|
|
|
-- Define various colours used from active colourscheme
|
|
|
|
local tab_bar_bg = "#333333" -- Not defined in scheme for some reason...
|
|
|
|
local tab_bg = scheme.foreground
|
|
|
|
local tab_fg = scheme.background
|
2023-02-14 12:01:37 +00:00
|
|
|
|
|
|
|
-- The elements to be formatted
|
|
|
|
local elements = {}
|
|
|
|
|
2023-02-14 18:00:43 +00:00
|
|
|
table.insert(elements, { Foreground = { Color = tab_bg } })
|
|
|
|
table.insert(elements, { Background = { Color = tab_bar_bg } })
|
2023-02-14 15:11:10 +00:00
|
|
|
table.insert(elements, { Text = SOLID_LEFT_ARROW })
|
2023-02-14 18:00:43 +00:00
|
|
|
while #cells > 1 do
|
|
|
|
local text = table.remove(cells, 1)
|
|
|
|
table.insert(elements, { Foreground = { Color = tab_fg } })
|
|
|
|
table.insert(elements, { Background = { Color = tab_bg } })
|
|
|
|
table.insert(elements, { Text = " " .. text .. " " })
|
|
|
|
table.insert(elements, { Foreground = { Color = tab_fg } })
|
|
|
|
table.insert(elements, { Text = LEFT_ARROW })
|
2023-02-14 12:01:37 +00:00
|
|
|
end
|
2023-02-14 18:00:43 +00:00
|
|
|
local text = table.remove(cells, 1)
|
|
|
|
table.insert(elements, { Foreground = { Color = tab_fg } })
|
|
|
|
table.insert(elements, { Background = { Color = tab_bg } })
|
|
|
|
table.insert(elements, { Text = " " .. text .. " " })
|
2023-02-14 12:01:37 +00:00
|
|
|
|
|
|
|
window:set_right_status(wezterm.format(elements))
|
|
|
|
end)
|