feat(wezterm): rainbow tabs
This commit is contained in:
parent
7b5f737001
commit
0a2d62a693
6 changed files with 231 additions and 190 deletions
|
@ -1,11 +1,53 @@
|
|||
local wezterm = require("wezterm")
|
||||
local fonts = require("fonts")
|
||||
|
||||
local DIVIDERS = {
|
||||
LEFT = utf8.char(0xe0be),
|
||||
RIGHT = utf8.char(0xe0bc),
|
||||
}
|
||||
|
||||
-- superscript/subscript
|
||||
local function numberStyle(number, script)
|
||||
local scripts = {
|
||||
superscript = {
|
||||
"⁰",
|
||||
"¹",
|
||||
"²",
|
||||
"³",
|
||||
"⁴",
|
||||
"⁵",
|
||||
"⁶",
|
||||
"⁷",
|
||||
"⁸",
|
||||
"⁹",
|
||||
},
|
||||
subscript = {
|
||||
"₀",
|
||||
"₁",
|
||||
"₂",
|
||||
"₃",
|
||||
"₄",
|
||||
"₅",
|
||||
"₆",
|
||||
"₇",
|
||||
"₈",
|
||||
"₉",
|
||||
},
|
||||
}
|
||||
local numbers = scripts[script]
|
||||
local number_string = tostring(number)
|
||||
local result = ""
|
||||
for i = 1, #number_string do
|
||||
local char = number_string:sub(i, i)
|
||||
local num = tonumber(char)
|
||||
if num then
|
||||
result = result .. numbers[num + 1]
|
||||
else
|
||||
result = result .. char
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- custom tab bar
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
|
||||
|
@ -18,7 +60,17 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
|
|||
end
|
||||
end
|
||||
|
||||
local active_bg = config.resolved_palette.ansi[6]
|
||||
local rainbow = {
|
||||
config.resolved_palette.ansi[2],
|
||||
config.resolved_palette.indexed[16],
|
||||
config.resolved_palette.ansi[4],
|
||||
config.resolved_palette.ansi[3],
|
||||
config.resolved_palette.ansi[5],
|
||||
config.resolved_palette.ansi[6]
|
||||
}
|
||||
|
||||
local i = (tab.tab_index) % 6
|
||||
local active_bg = rainbow[i + 1]
|
||||
local active_fg = colours.background
|
||||
local inactive_bg = colours.inactive_tab.bg_color
|
||||
local inactive_fg = colours.inactive_tab.fg_color
|
||||
|
@ -42,7 +94,7 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
|
|||
elseif tab.tab_index == active_tab_index - 1 then
|
||||
s_bg = inactive_bg
|
||||
s_fg = inactive_fg
|
||||
e_bg = active_bg
|
||||
e_bg = rainbow[(i + 1) % 6 + 1]
|
||||
e_fg = inactive_bg
|
||||
elseif tab.is_active then
|
||||
s_bg = active_bg
|
||||
|
@ -56,7 +108,8 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
|
|||
e_fg = inactive_bg
|
||||
end
|
||||
|
||||
local muxpanes = wezterm.mux.get_tab(tab.tab_id):panes()
|
||||
local tabi = wezterm.mux.get_tab(tab.tab_id)
|
||||
local muxpanes = tabi:panes()
|
||||
local count = #muxpanes == 1 and "" or #muxpanes
|
||||
local index = tab.tab_index + 1 .. ": "
|
||||
|
||||
|
@ -64,7 +117,7 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
|
|||
{ Background = { Color = s_bg } },
|
||||
{ Foreground = { Color = s_fg } },
|
||||
{
|
||||
Text = " " .. index .. tab.active_pane.title .. fonts.numberStyle(count, "superscript") .. " ",
|
||||
Text = " " .. index .. tab.active_pane.title .. numberStyle(count, "superscript") .. " ",
|
||||
},
|
||||
{ Background = { Color = e_bg } },
|
||||
{ Foreground = { Color = e_fg } },
|
||||
|
@ -72,19 +125,40 @@ wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_wid
|
|||
}
|
||||
end)
|
||||
|
||||
local function arrContains(arr, val)
|
||||
for _, v in ipairs(arr) do
|
||||
if v == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local nonpadded_apps = { "nvim", "btop", "btm" }
|
||||
|
||||
wezterm.on("smartpadding", function(window, pane)
|
||||
local fgp = pane:get_foreground_process_info()
|
||||
if fgp == nil then return
|
||||
elseif arrContains(nonpadded_apps, fgp.name) then
|
||||
window:set_config_overrides({ window_padding = { left = 0, right = 0, top = 0, bottom = 0 } })
|
||||
else window:set_config_overrides({ window_padding = wezterm.GLOBAL.smart_padding }) end
|
||||
end)
|
||||
|
||||
-- custom status
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
wezterm.on("update-status", function(window, pane)
|
||||
local palette = window:effective_config().resolved_palette
|
||||
local firstTabActive = window:mux_window():tabs_with_info()[1].is_active
|
||||
|
||||
local leader_text = " "
|
||||
|
||||
if window:leader_is_active() then
|
||||
leader_text = " "
|
||||
if wezterm.GLOBAL.smart_padding ~= nil then
|
||||
wezterm.emit("smartpadding", window, pane)
|
||||
end
|
||||
|
||||
local divider_bg = firstTabActive and palette.ansi[6] or palette.tab_bar.inactive_tab.bg_color
|
||||
local palette = window:effective_config().resolved_palette
|
||||
local first_tab_active = window:mux_window():tabs_with_info()[1].is_active
|
||||
|
||||
local leader_text = " "
|
||||
if window:leader_is_active() then leader_text = " " end
|
||||
|
||||
local divider_bg = first_tab_active and palette.ansi[2] or palette.tab_bar.inactive_tab.bg_color
|
||||
|
||||
window:set_left_status(wezterm.format({
|
||||
{ Foreground = { Color = palette.background } },
|
||||
|
@ -95,7 +169,7 @@ wezterm.on("update-status", function(window, pane)
|
|||
{ Text = DIVIDERS.RIGHT },
|
||||
}))
|
||||
window:set_right_status(wezterm.format({
|
||||
{ Background = { Color = palette.background } },
|
||||
{ Background = { Color = palette.tab_bar.background } },
|
||||
{ Foreground = { Color = palette.ansi[6] } },
|
||||
{ Text = os.date(" %H:%M ") },
|
||||
}))
|
||||
|
|
|
@ -32,55 +32,9 @@ M.get_font = function(name)
|
|||
}
|
||||
|
||||
return {
|
||||
font = wezterm.font_with_fallback({
|
||||
fonts[name].font,
|
||||
"Apple Color Emoji",
|
||||
}),
|
||||
font = wezterm.font(fonts[name].font),
|
||||
size = fonts[name].size,
|
||||
}
|
||||
end
|
||||
|
||||
-- superscript/subscript
|
||||
M.numberStyle = function(number, script)
|
||||
local scripts = {
|
||||
superscript = {
|
||||
"⁰",
|
||||
"¹",
|
||||
"²",
|
||||
"³",
|
||||
"⁴",
|
||||
"⁵",
|
||||
"⁶",
|
||||
"⁷",
|
||||
"⁸",
|
||||
"⁹",
|
||||
},
|
||||
subscript = {
|
||||
"₀",
|
||||
"₁",
|
||||
"₂",
|
||||
"₃",
|
||||
"₄",
|
||||
"₅",
|
||||
"₆",
|
||||
"₇",
|
||||
"₈",
|
||||
"₉",
|
||||
},
|
||||
}
|
||||
local numbers = scripts[script]
|
||||
local number_string = tostring(number)
|
||||
local result = ""
|
||||
for i = 1, #number_string do
|
||||
local char = number_string:sub(i, i)
|
||||
local num = tonumber(char)
|
||||
if num then
|
||||
result = result .. numbers[num + 1]
|
||||
else
|
||||
result = result .. char
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -6,51 +6,51 @@ return {
|
|||
{
|
||||
key = "\\",
|
||||
mods = "LEADER",
|
||||
action = act({ SplitHorizontal = { domain = "CurrentPaneDomain" } }),
|
||||
action = act.SplitHorizontal({ domain = "CurrentPaneDomain" }),
|
||||
},
|
||||
-- and 'Minus' to split vertically
|
||||
{
|
||||
key = "-",
|
||||
mods = "LEADER",
|
||||
action = act({ SplitVertical = { domain = "CurrentPaneDomain" } }),
|
||||
action = act.SplitVertical({ domain = "CurrentPaneDomain" }),
|
||||
},
|
||||
-- 'hjkl' to move between panes
|
||||
{ key = "h", mods = "LEADER", action = act({ ActivatePaneDirection = "Left" }) },
|
||||
{ key = "j", mods = "LEADER", action = act({ ActivatePaneDirection = "Down" }) },
|
||||
{ key = "k", mods = "LEADER", action = act({ ActivatePaneDirection = "Up" }) },
|
||||
{ key = "l", mods = "LEADER", action = act({ ActivatePaneDirection = "Right" }) },
|
||||
{ key = "h", mods = "LEADER", action = act.ActivatePaneDirection("Left")},
|
||||
{ key = "j", mods = "LEADER", action = act.ActivatePaneDirection("Down")},
|
||||
{ key = "k", mods = "LEADER", action = act.ActivatePaneDirection("Up") },
|
||||
{ key = "l", mods = "LEADER", action = act.ActivatePaneDirection("Right") },
|
||||
-- -- Shift + 'hjkl' to resize panes
|
||||
{ key = "h", mods = "LEADER|SHIFT", action = act({ AdjustPaneSize = { "Left", 5 } }) },
|
||||
{ key = "j", mods = "LEADER|SHIFT", action = act({ AdjustPaneSize = { "Down", 5 } }) },
|
||||
{ key = "k", mods = "LEADER|SHIFT", action = act({ AdjustPaneSize = { "Up", 5 } }) },
|
||||
{ key = "l", mods = "LEADER|SHIFT", action = act({ AdjustPaneSize = { "Right", 5 } }) },
|
||||
{ key = "h", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Left", 5}) },
|
||||
{ key = "j", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Down", 5}) },
|
||||
{ key = "k", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Up", 5}) },
|
||||
{ key = "l", mods = "LEADER|SHIFT", action = act.AdjustPaneSize({"Right", 5}) },
|
||||
-- numbers to navigate to tabs
|
||||
{ key = "1", mods = "LEADER", action = act({ ActivateTab = 0 }) },
|
||||
{ key = "2", mods = "LEADER", action = act({ ActivateTab = 1 }) },
|
||||
{ key = "3", mods = "LEADER", action = act({ ActivateTab = 2 }) },
|
||||
{ key = "4", mods = "LEADER", action = act({ ActivateTab = 3 }) },
|
||||
{ key = "5", mods = "LEADER", action = act({ ActivateTab = 4 }) },
|
||||
{ key = "6", mods = "LEADER", action = act({ ActivateTab = 5 }) },
|
||||
{ key = "7", mods = "LEADER", action = act({ ActivateTab = 6 }) },
|
||||
{ key = "8", mods = "LEADER", action = act({ ActivateTab = 7 }) },
|
||||
{ key = "9", mods = "LEADER", action = act({ ActivateTab = 8 }) },
|
||||
{ key = "9", mods = "LEADER", action = act({ ActivateTab = 9 }) },
|
||||
{ key = "0", mods = "LEADER", action = act({ ActivateTab = -1 }) },
|
||||
{ key = "1", mods = "SUPER", action = act({ ActivateTab = 0 }) },
|
||||
{ key = "2", mods = "SUPER", action = act({ ActivateTab = 1 }) },
|
||||
{ key = "3", mods = "SUPER", action = act({ ActivateTab = 2 }) },
|
||||
{ key = "4", mods = "SUPER", action = act({ ActivateTab = 3 }) },
|
||||
{ key = "5", mods = "SUPER", action = act({ ActivateTab = 4 }) },
|
||||
{ key = "6", mods = "SUPER", action = act({ ActivateTab = 5 }) },
|
||||
{ key = "7", mods = "SUPER", action = act({ ActivateTab = 6 }) },
|
||||
{ key = "8", mods = "SUPER", action = act({ ActivateTab = 7 }) },
|
||||
{ key = "9", mods = "SUPER", action = act({ ActivateTab = 8 }) },
|
||||
{ key = "9", mods = "SUPER", action = act({ ActivateTab = 9 }) },
|
||||
{ key = "0", mods = "SUPER", action = act({ ActivateTab = -1 }) },
|
||||
{ key = "1", mods = "LEADER", action = act.ActivateTab(0) },
|
||||
{ key = "2", mods = "LEADER", action = act.ActivateTab(1) },
|
||||
{ key = "3", mods = "LEADER", action = act.ActivateTab(2) },
|
||||
{ key = "4", mods = "LEADER", action = act.ActivateTab(3) },
|
||||
{ key = "5", mods = "LEADER", action = act.ActivateTab(4) },
|
||||
{ key = "6", mods = "LEADER", action = act.ActivateTab(5) },
|
||||
{ key = "7", mods = "LEADER", action = act.ActivateTab(6) },
|
||||
{ key = "8", mods = "LEADER", action = act.ActivateTab(7) },
|
||||
{ key = "9", mods = "LEADER", action = act.ActivateTab(8) },
|
||||
{ key = "9", mods = "LEADER", action = act.ActivateTab(9) },
|
||||
{ key = "0", mods = "LEADER", action = act.ActivateTab(-1) },
|
||||
{ key = "1", mods = "SUPER", action = act.ActivateTab(0) },
|
||||
{ key = "2", mods = "SUPER", action = act.ActivateTab(1) },
|
||||
{ key = "3", mods = "SUPER", action = act.ActivateTab(2) },
|
||||
{ key = "4", mods = "SUPER", action = act.ActivateTab(3) },
|
||||
{ key = "5", mods = "SUPER", action = act.ActivateTab(4) },
|
||||
{ key = "6", mods = "SUPER", action = act.ActivateTab(5) },
|
||||
{ key = "7", mods = "SUPER", action = act.ActivateTab(6) },
|
||||
{ key = "8", mods = "SUPER", action = act.ActivateTab(7) },
|
||||
{ key = "9", mods = "SUPER", action = act.ActivateTab(8) },
|
||||
{ key = "9", mods = "SUPER", action = act.ActivateTab(9) },
|
||||
{ key = "0", mods = "SUPER", action = act.ActivateTab(-1) },
|
||||
-- 'c' to create a new tab
|
||||
{ key = "c", mods = "LEADER", action = act({ SpawnTab = "CurrentPaneDomain" }) },
|
||||
{ key = "c", mods = "LEADER", action = act.SpawnTab("CurrentPaneDomain") },
|
||||
-- 'x' to kill the current pane
|
||||
{ key = "x", mods = "LEADER", action = act({ CloseCurrentPane = { confirm = true } }) },
|
||||
{ key = "x", mods = "LEADER", action = act.CloseCurrentPane({ confirm = true }) },
|
||||
-- 'z' to toggle the zoom for the current pane
|
||||
{ key = "z", mods = "LEADER", action = "TogglePaneZoomState" },
|
||||
-- 'v' to visually select in the current pane
|
||||
|
|
|
@ -19,9 +19,14 @@ M.get_custom_colorschemes = function()
|
|||
oledppuccin.tab_bar.background = "#040404"
|
||||
oledppuccin.tab_bar.inactive_tab.bg_color = "#0f0f0f"
|
||||
oledppuccin.tab_bar.new_tab.bg_color = "#080808"
|
||||
oledppuccin.ansi[6] = "#c6a0f6"
|
||||
|
||||
local latte = wezterm.color.get_builtin_schemes()["Catppuccin Latte"]
|
||||
latte.ansi[6] = "#8839ef"
|
||||
|
||||
return {
|
||||
["OLEDppuccin"] = oledppuccin,
|
||||
["Catppuccin Latte"] = latte,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
1
dot_config/wezterm/tlconfig.lua
Normal file
1
dot_config/wezterm/tlconfig.lua
Normal file
|
@ -0,0 +1 @@
|
|||
return {}
|
|
@ -5,6 +5,13 @@ require("bar")
|
|||
|
||||
local font = fonts.get_font("berkeley")
|
||||
|
||||
-- wezterm.GLOBAL.smart_padding = {
|
||||
-- left = 12,
|
||||
-- right = 12,
|
||||
-- top = 0,
|
||||
-- bottom = 0,
|
||||
-- }
|
||||
|
||||
return {
|
||||
-- keys
|
||||
disable_default_key_bindings = true,
|
||||
|
@ -32,12 +39,12 @@ return {
|
|||
light = "Catppuccin Latte",
|
||||
}),
|
||||
-- tab bar
|
||||
hide_tab_bar_if_only_one_tab = false,
|
||||
tab_bar_at_bottom = true,
|
||||
tab_max_width = 32,
|
||||
use_fancy_tab_bar = false,
|
||||
-- etc.
|
||||
adjust_window_size_when_changing_font_size = false,
|
||||
use_resize_increments = true,
|
||||
audible_bell = "Disabled",
|
||||
clean_exit_codes = { 130 },
|
||||
default_cursor_style = "BlinkingBar",
|
||||
|
|
Loading…
Reference in a new issue