feat(wezterm): use superscript for pane count

This commit is contained in:
winston 2022-09-20 18:56:10 +02:00
parent a08e6ec75e
commit 2e8bdd0036
Signed by: winston
GPG key ID: 3786770EDBC2B481

View file

@ -54,7 +54,6 @@ local function get_font(name)
return { return {
font = wezterm.font_with_fallback({ font = wezterm.font_with_fallback({
fonts[name].font, fonts[name].font,
"Nerd Font Symbols",
"Apple Color Emoji", "Apple Color Emoji",
}), }),
size = fonts[name].size, size = fonts[name].size,
@ -62,8 +61,35 @@ local function get_font(name)
end end
-- }}} -- }}}
local function superscript(number)
local numbers = {
"",
"¹",
"²",
"³",
"",
"",
"",
"",
"",
"",
}
local number_string = tostring(number)
local result = ""
for i = 1, #number_string do
local char = number_string:sub(i, i)
local number = tonumber(char)
if number then
result = result .. numbers[number + 1]
else
result = result .. char
end
end
return result
end
-- custom tab bar {{{ -- custom tab bar {{{
---@diagnostic disable-next-line: unused-local -- @diagnostic disable-next-line: unused-local
wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width) wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
local RIGHT_DIVIDER = utf8.char(0xe0bc) local RIGHT_DIVIDER = utf8.char(0xe0bc)
local colours = config.resolved_palette.tab_bar local colours = config.resolved_palette.tab_bar
@ -112,10 +138,14 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
e_bg = inactive_bg e_bg = inactive_bg
e_fg = inactive_bg e_fg = inactive_bg
end end
local muxpanes = wezterm.mux.get_tab(tab.tab_id):panes()
local count = #muxpanes == 1 and "" or #muxpanes .. " "
return { return {
{ Background = { Color = s_bg } }, { Background = { Color = s_bg } },
{ Foreground = { Color = s_fg } }, { Foreground = { Color = s_fg } },
{ Text = " " .. tab.tab_index + 1 .. ": " .. tab.active_pane.title .. " " }, { Text = " " .. tab.tab_index + 1 .. ": " .. tab.active_pane.title .. superscript(count) .. " " },
{ Background = { Color = e_bg } }, { Background = { Color = e_bg } },
{ Foreground = { Color = e_fg } }, { Foreground = { Color = e_fg } },
{ Text = RIGHT_DIVIDER }, { Text = RIGHT_DIVIDER },
@ -123,6 +153,7 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
end) end)
-- }}} -- }}}
local function get_os() local function get_os()
local target = wezterm.target_triple local target = wezterm.target_triple
if string.find(target, "linux") then if string.find(target, "linux") then
@ -222,4 +253,6 @@ return {
color_scheme = scheme_for_appearance(wezterm.gui.get_appearance()), color_scheme = scheme_for_appearance(wezterm.gui.get_appearance()),
-- nightly only -- nightly only
clean_exit_codes = { 130 }, clean_exit_codes = { 130 },
-- bell
audible_bell = "Disabled"
} }