feat: user customization for tabline

-- feat: Allows for user overrides to customize the tabline appearance
-- fix: Hide battery component in default tabline layout when no
batteries are found
This commit is contained in:
2024-10-04 12:44:54 -04:00
parent c0775afb63
commit ff6443e145
3 changed files with 75 additions and 3 deletions
+59
View File
@@ -96,6 +96,8 @@ The rootiest WezTerm configuration you will ever see!
User customizations can be added by creating a `user.lua` file in the User customizations can be added by creating a `user.lua` file in the
`~/.config/wezterm` directory. `~/.config/wezterm` directory.
### General Configuration
The file should be structured in the following manner: The file should be structured in the following manner:
```lua ```lua
@@ -142,6 +144,63 @@ These global variables will be detected and used to apply the encryption.
As with the default configuration, if the keyfile is not found, encryption is disabled. As with the default configuration, if the keyfile is not found, encryption is disabled.
### Tabline Customization
The tabline configuration can also be customized.
This is done by adding (above the `return{}` table):
```lua
local wezterm = WEZTERM -- Link to the main wezterm object
MYTABLINE = {
options = {
icons_enabled = true,
theme = 'Catppuccin Mocha',
color_overrides = {},
section_separators = {
left = wezterm.nerdfonts.pl_left_hard_divider,
right = wezterm.nerdfonts.pl_right_hard_divider,
},
component_separators = {
left = wezterm.nerdfonts.pl_left_soft_divider,
right = wezterm.nerdfonts.pl_right_soft_divider,
},
tab_separators = {
left = wezterm.nerdfonts.pl_left_hard_divider,
right = wezterm.nerdfonts.pl_right_hard_divider,
},
},
sections = {
tabline_a = { 'mode' },
tabline_b = { 'workspace' },
tabline_c = { ' ' },
tab_active = {
'index',
{ 'parent', padding = 0 },
'/',
{ 'cwd', padding = { left = 0, right = 1 } },
{ 'zoomed', padding = 0 },
},
tab_inactive = { 'index', { 'process', padding = { left = 0, right = 1 } } },
tabline_x = { 'ram', 'cpu' },
tabline_y = { 'datetime', 'battery' },
tabline_z = { 'hostname' },
},
extensions = {},
}
return {
-- Etc..
}
```
The table above is taken from the example in the
[tabline.wez documentation](https://github.com/michaelbrusegard/tabline.wez?tab=readme-ov-file#default-configuration).
This is the table that will be passed to `tabline.setup()`
and loaded by the tabline plugin.
## Screenshots ## Screenshots
![Rootiest WezTerm](.screenshots/term.png) ![Rootiest WezTerm](.screenshots/term.png)
+1
View File
@@ -33,6 +33,7 @@ if USERCONFIG then
else else
MYKEY = nil MYKEY = nil
MYPUBKEY = nil MYPUBKEY = nil
MYTAB_BAR = nil
end end
-- Return config options table -- Return config options table
+15 -3
View File
@@ -6,7 +6,7 @@ local batteries = BATTERIES
local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez") local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez")
tabline.setup({ local tab_opts = {
options = { options = {
icons_enabled = true, icons_enabled = true,
theme = "Catppuccin Mocha", theme = "Catppuccin Mocha",
@@ -97,11 +97,23 @@ tabline.setup({
}, },
tabline_z = { tabline_z = {
{ "hostname", padding = { left = 0, right = 1 } }, { "hostname", padding = { left = 0, right = 1 } },
batteries.get_battery_icons,
}, },
}, },
extensions = { "resurrect" }, extensions = { "resurrect" },
}) }
if batteries.get_battery_icons() ~= "" then
tab_opts.sections.tabline_z = {
{ "hostname", padding = { left = 0, right = 1 } },
batteries.get_battery_icons,
}
end
if MYTABLINE ~= nil then
tab_opts = MYTABLINE
end
tabline.setup(tab_opts)
local function apply_tabline_config(conf) local function apply_tabline_config(conf)
conf.use_fancy_tab_bar = false conf.use_fancy_tab_bar = false