nixos/old/config/wezterm/tab_bar_style.lua

61 lines
2.3 KiB
Lua

local wezterm = require "wezterm"
-- The filled in variant of the powerline ) symbol
local SOLID_RIGHT_SEP = require("utf8").char(0xe0b4)
local M = {}
M.setup = function(scheme)
wezterm.on("format-tab-title", function(tab, tabs, _, _, hover, max_width)
local text_fg
if tab.is_active then
text_fg = scheme.tab_bar.active_tab.fg_color
else
text_fg = scheme.tab_bar.inactive_tab.fg_color
end
local title = wezterm.truncate_right(tab.active_pane.title, max_width - 2)
local colours = wezterm.color.gradient({
colors = { scheme.tab_bar.active_tab.bg_color, scheme.tab_bar.new_tab.bg_color },
}, #tabs + 1)
local elements = {}
table.insert(elements, "ResetAttributes")
table.insert(elements, { Background = { Color = colours[tab.tab_index + 1] } })
table.insert(elements, { Foreground = { Color = text_fg } })
table.insert(elements, { Text = " " })
if tab.is_active then
table.insert(elements, { Attribute = { Underline = "Single" } })
table.insert(elements, { Attribute = { Intensity = "Bold" } })
end
if hover then table.insert(elements, { Attribute = { Italic = true } }) end
table.insert(elements, { Text = title })
table.insert(elements, "ResetAttributes")
table.insert(elements, { Background = { Color = colours[tab.tab_index + 2] } })
table.insert(elements, { Foreground = { Color = colours[tab.tab_index + 1] } })
table.insert(elements, { Text = SOLID_RIGHT_SEP })
table.insert(elements, "ResetAttributes")
return elements
end)
end
M._new_tab_format = function(scheme)
return {
{ Background = { Color = scheme.tab_bar.new_tab.bg_color } },
{ Foreground = { Color = scheme.tab_bar.new_tab.fg_color } },
{ Text = " +" },
"ResetAttributes",
{ Background = { Color = scheme.tab_bar.background } },
{ Foreground = { Color = scheme.tab_bar.new_tab.bg_color } },
{ Text = SOLID_RIGHT_SEP },
"ResetAttributes",
}
end
M.new_tab = function(scheme) return wezterm.format(M._new_tab_format(scheme)) end
M.new_tab_hover = function(scheme)
local format = M._new_tab_format(scheme)
table.insert(format, 1, { Attribute = { Italic = true } })
return wezterm.format(format)
end
return M