Last active
July 10, 2024 21:21
-
-
Save gsuuon/5511f0aa10c10c6cbd762e0b3e596b71 to your computer and use it in GitHub Desktop.
My styled wezterm config - just the relevant bits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local wezterm = require 'wezterm' | |
local color_default_fg_light = wezterm.color.parse("#cacaca") -- ๐ฉ | |
local color_default_fg_dark = wezterm.color.parse("#303030") | |
return { | |
VERIDIAN = { | |
bg = wezterm.color.parse("#4D8060"), | |
fg = color_default_fg_light | |
}, | |
PAYNE = { | |
bg = wezterm.color.parse("#385F71"), | |
fg = color_default_fg_light | |
}, | |
INDIGO = { | |
bg = wezterm.color.parse("#7C77B9"), | |
fg = color_default_fg_light | |
}, | |
CAROLINA = { | |
bg = wezterm.color.parse("#8FBFE0"), | |
fg = color_default_fg_dark | |
}, | |
FLAME = { | |
bg = wezterm.color.parse("#D36135"), | |
fg = color_default_fg_dark | |
}, | |
JET = { | |
bg = wezterm.color.parse("#282B28"), | |
fg = color_default_fg_light | |
}, | |
TAUPE = { | |
bg = wezterm.color.parse("#785964"), | |
fg = color_default_fg_light | |
}, | |
ECRU = { | |
bg = wezterm.color.parse("#C6AE82"), | |
fg = color_default_fg_dark | |
}, | |
VIOLET = { | |
bg = wezterm.color.parse("#685F74"), | |
fg = color_default_fg_light | |
}, | |
VERDIGRIS = { | |
bg = wezterm.color.parse("#28AFB0"), | |
fg = color_default_fg_light | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local wezterm = require 'wezterm' | |
local color = (function() | |
local COLOR = require "colors" | |
local coolors = { | |
COLOR.VERIDIAN, | |
COLOR.PAYNE, | |
COLOR.INDIGO, | |
COLOR.CAROLINA, | |
COLOR.FLAME, | |
COLOR.JET, | |
COLOR.TAUPE, | |
COLOR.ECRU, | |
COLOR.VIOLET, | |
COLOR.VERDIGRIS | |
} | |
return coolors[math.random(#coolors)] | |
end)() | |
local color_primary = color | |
local title_color_bg = color_primary.bg | |
local title_color_fg = color_primary.fg | |
local color_off = title_color_bg:lighten(0.4) | |
local color_on = color_off:lighten(0.4) | |
wezterm.on('update-right-status', function(window) | |
local bat = '' | |
local b = wezterm.battery_info()[1] | |
bat = wezterm.format { | |
{ Foreground = { | |
Color = | |
b.state_of_charge > 0.2 and color_on or color_off, | |
} }, | |
{ Text = 'โ' }, | |
{ Foreground = { | |
Color = | |
b.state_of_charge > 0.4 and color_on or color_off, | |
} }, | |
{ Text = 'โ' }, | |
{ Foreground = { | |
Color = | |
b.state_of_charge > 0.6 and color_on or color_off, | |
} }, | |
{ Text = 'โ' }, | |
{ Foreground = { | |
Color = | |
b.state_of_charge > 0.8 and color_on or color_off, | |
} }, | |
{ Text = 'โ' }, | |
{ Background = { | |
Color = | |
b.state_of_charge > 0.98 and color_on or color_off, | |
} }, | |
{ Foreground = { | |
Color = | |
b.state == "Charging" | |
and color_on:lighten(0.3):complement() | |
or | |
(b.state_of_charge < 0.2 and wezterm.GLOBAL.count % 2 == 0) | |
and color_on:lighten(0.1):complement() | |
or color_off:darken(0.1) | |
} }, | |
{ Text = ' โก ' }, | |
} | |
local time = wezterm.strftime '%-l:%M %P' | |
local bg1 = title_color_bg:lighten(0.1) | |
local bg2 = title_color_bg:lighten(0.2) | |
window:set_right_status( | |
wezterm.format { | |
{ Background = { Color = title_color_bg } }, | |
{ Foreground = { Color = bg1 } }, | |
{ Text = '๎พ' }, | |
{ Background = { Color = title_color_bg:lighten(0.1) } }, | |
{ Foreground = { Color = title_color_fg } }, | |
{ Text = ' ' .. window:active_workspace() .. ' ' }, | |
{ Foreground = { Color = bg1 } }, | |
{ Background = { Color = bg2 } }, | |
{ Text = '๎ธ' }, | |
{ Foreground = { Color = title_color_bg:lighten(0.4) } }, | |
{ Foreground = { Color = title_color_fg } }, | |
{ Text = ' ' .. time .. ' ' .. bat } | |
} | |
) | |
end) | |
wezterm.on('gui-startup', function(cmd) | |
local mux = wezterm.mux | |
local padSize = 80 | |
local screenWidth = 2560 | |
local screenHeight = 1600 | |
local tab, pane, window = mux.spawn_window(cmd or { | |
workspace = 'main', | |
}) | |
local icons = { | |
'๐', | |
'๐ง', | |
'๐ซ ', | |
'๐๏ธ', | |
'๐', | |
'๐ช', | |
'๐ง ', | |
'๐ฆฅ', | |
'๐ฆ', | |
'๐', | |
'๐ฎ', | |
'๐', | |
'๐ง', | |
'๐ฅ', | |
'๐', | |
} | |
tab:set_title(' ' .. icons[math.random(#icons)] .. ' ') | |
if window ~= nil then | |
window:gui_window():set_position(padSize, padSize) | |
window:gui_window():set_inner_size(screenWidth - (padSize * 2), screenHeight - (padSize * 2) - 48) | |
end | |
end) | |
local TAB_EDGE_LEFT = wezterm.nerdfonts.ple_left_half_circle_thick | |
local TAB_EDGE_RIGHT = wezterm.nerdfonts.ple_right_half_circle_thick | |
local function tab_title(tab_info) | |
local title = tab_info.tab_title | |
if title and #title > 0 then return title end | |
return tab_info.active_pane.title:gsub("%.exe", "") | |
end | |
wezterm.on( | |
'format-tab-title', | |
function(tab, _, _, _, hover, max_width) | |
local edge_background = title_color_bg | |
local background = title_color_bg:lighten(0.05) | |
local foreground = title_color_fg | |
if tab.is_active then | |
background = background:lighten(0.1) | |
foreground = foreground:lighten(0.1) | |
elseif hover then | |
background = background:lighten(0.2) | |
foreground = foreground:lighten(0.2) | |
end | |
local edge_foreground = background | |
local title = tab_title(tab) | |
-- ensure that the titles fit in the available space, | |
-- and that we have room for the edges. | |
title = wezterm.truncate_right(title, max_width - 2) | |
return { | |
{ Background = { Color = edge_background } }, | |
{ Foreground = { Color = edge_foreground } }, | |
{ Text = TAB_EDGE_LEFT }, | |
{ Background = { Color = background } }, | |
{ Foreground = { Color = foreground } }, | |
{ Text = title }, | |
{ Background = { Color = edge_background } }, | |
{ Foreground = { Color = edge_foreground } }, | |
{ Text = TAB_EDGE_RIGHT }, | |
} | |
end | |
) | |
return { | |
colors = { | |
tab_bar = { | |
active_tab = { | |
bg_color = title_color_bg:lighten(0.03), | |
fg_color = title_color_fg:lighten(0.8), | |
intensity = "Bold", | |
}, | |
inactive_tab = { | |
bg_color = title_color_bg:lighten(0.01), | |
fg_color = title_color_fg, | |
intensity = "Half", | |
}, | |
inactive_tab_edge = title_color_bg | |
}, | |
split = title_color_bg:lighten(0.3):desaturate(0.5) | |
}, | |
window_background_opacity = 0.6, | |
window_frame = { | |
active_titlebar_bg = title_color_bg, | |
inactive_titlebar_bg = title_color_bg, | |
font_size = 10.0, | |
}, | |
window_decorations = 'RESIZE', | |
win32_system_backdrop = "Acrylic", | |
show_tab_index_in_tab_bar = false, | |
show_new_tab_button_in_tab_bar = false, | |
} |
I'll try to remember to comment here when I make the plugin, I'm partly waiting to see if wez/wezterm#4248 gets merged and plugins get documented before doing that.
I might write up a little gist for this sometime.
Go for it, seems interesting! I was planning to try setting the workspace color in env and doing some dynamic colorscheme generation, that may be helpful.
Wrote the gist, have fun :)
(Still interested in that workspace indiciator ๐)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh and something I just realized: this throws an error if there is no battery present (desktop PC).
I ended up with this: