Customise wezterm statusbar and colouring

This commit is contained in:
Evie Litherland-Smith 2023-02-14 15:11:10 +00:00
parent 66793d4c22
commit c6c03d2b37
3 changed files with 23 additions and 41 deletions

View file

@ -4,4 +4,4 @@ require("nightfox").setup({
}, },
}) })
require("nightfox").compile() require("nightfox").compile()
vim.cmd("colorscheme nightfox") vim.cmd("colorscheme duskfox")

View file

@ -4,34 +4,13 @@ wezterm.on("update-right-status", function(window, pane)
-- Each element holds the text for a cell in a "powerline" style << fade -- Each element holds the text for a cell in a "powerline" style << fade
local cells = {} local cells = {}
-- Figure out the cwd and host of the current pane.
-- This will pick up the hostname for the remote host if your
-- shell is using OSC 7 on the remote host.
local cwd_uri = pane:get_current_working_dir()
if cwd_uri then
cwd_uri = cwd_uri:sub(8)
local slash = cwd_uri:find("/")
local cwd = ""
local hostname = ""
if slash then
hostname = cwd_uri:sub(1, slash - 1)
-- Remove the domain name portion of the hostname
local dot = hostname:find("[.]")
if dot then
hostname = hostname:sub(1, dot - 1)
end
-- and extract the cwd from the uri
cwd = cwd_uri:sub(slash)
table.insert(cells, cwd)
table.insert(cells, hostname)
end
end
-- I like my date/time in this style: "Wed Mar 3 08:14" -- I like my date/time in this style: "Wed Mar 3 08:14"
local date = wezterm.strftime("%a %b %-d %H:%M") local date = wezterm.strftime("%a %b %-d %H:%M")
table.insert(cells, date) table.insert(cells, date)
-- Get current hostname to track which device I'm on
table.insert(cells, wezterm.hostname())
-- An entry for each battery (typically 0 or 1 battery) -- An entry for each battery (typically 0 or 1 battery)
for _, b in ipairs(wezterm.battery_info()) do for _, b in ipairs(wezterm.battery_info()) do
table.insert(cells, string.format("%.0f%%", b.state_of_charge * 100)) table.insert(cells, string.format("%.0f%%", b.state_of_charge * 100))
@ -41,6 +20,7 @@ wezterm.on("update-right-status", function(window, pane)
local name = window:active_key_table() local name = window:active_key_table()
if name then if name then
name = "TABLE: " .. name name = "TABLE: " .. name
table.insert(cells, name)
end end
-- The powerline < symbol -- The powerline < symbol
@ -49,16 +29,16 @@ wezterm.on("update-right-status", function(window, pane)
local SOLID_LEFT_ARROW = utf8.char(0xe0b2) local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
-- Color palette for the backgrounds of each cell -- Color palette for the backgrounds of each cell
local colors = { local colors = wezterm.color.gradient({
"#3c1361", colors = {
"#52307c", "#333333",
"#663a82", "#926ee4",
"#7c5295", -- "#9ccfd8",
"#b491c8", },
} }, #cells + 1)
-- Foreground color for the text across the fade -- Foreground color for the text across the fade
local text_fg = "#c0c0c0" local text_fg = wezterm.color.get_builtin_schemes()["duskfox"].foreground
-- The elements to be formatted -- The elements to be formatted
local elements = {} local elements = {}
@ -66,20 +46,21 @@ wezterm.on("update-right-status", function(window, pane)
local num_cells = 0 local num_cells = 0
-- Translate a cell into elements -- Translate a cell into elements
function push(text, is_last) local function push(text, is_last)
local cell_no = num_cells + 1 local cell_no = num_cells + 1
table.insert(elements, { Foreground = { Color = text_fg } }) table.insert(elements, { Foreground = { Color = text_fg } })
table.insert(elements, { Background = { Color = colors[cell_no] } }) table.insert(elements, { Background = { Color = colors[cell_no + 1] } })
table.insert(elements, { Text = " " .. text .. " " }) table.insert(elements, { Text = " " .. text .. " " })
if not is_last then if not is_last then
table.insert(elements, { Foreground = { Color = colors[cell_no + 1] } }) table.insert(elements, { Foreground = { Color = colors[cell_no + 2] } })
table.insert(elements, { Text = SOLID_LEFT_ARROW }) table.insert(elements, { Text = SOLID_LEFT_ARROW })
end end
num_cells = num_cells + 1 num_cells = num_cells + 1
end end
table.insert(elements, { Foreground = { Color = colors[num_cells + 1] } }) table.insert(elements, { Foreground = { Color = colors[num_cells + 2] } })
table.insert(elements, { Text = SOLID_LEFT_ARROW }) table.insert(elements, { Background = { Color = colors[1] } })
table.insert(elements, { Text = SOLID_LEFT_ARROW })
while #cells > 0 do while #cells > 0 do
local cell = table.remove(cells, 1) local cell = table.remove(cells, 1)
push(cell, #cells == 0) push(cell, #cells == 0)

View file

@ -3,10 +3,11 @@ require("navigator")
return { return {
font_size = 14, font_size = 14,
disable_default_key_bindings = true,
window_background_opacity = 0.95, window_background_opacity = 0.95,
color_scheme = "nightfox", window_decorations = "RESIZE",
use_dead_keys = false, color_scheme = "duskfox",
disable_default_key_bindings = true,
keys = require("keys"), keys = require("keys"),
key_tables = require("key_tables"), key_tables = require("key_tables"),
use_dead_keys = false,
} }