1
0
Fork 0

wezterm: major config rework

This commit is contained in:
Von Random 2023-01-21 12:53:08 +02:00
parent 3df18892ec
commit d419a62baa

View file

@ -1,80 +1,54 @@
local wt = require 'wezterm' local wt = require('wezterm')
local act = wt.action local act = wt.action
local fontsize_darwin = 14 local font = 'Cascadia Code PL'
local fontsize_others = 11 local font_features = { 'ss01=1', 'ss02=1', 'ss19=1' }
local theme_n = 0 local fontsizes = { Darwin = 14, others = 11 }
local themes = { local themes = { dark = 'Gruvbox Dark', light = 'PencilLight' }
'BirdsOfParadise', local theme = themes.dark
'Blazer', local overrides = {
'BlueBerryPie', fonts = { harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' } },
'Dark+', -- another great one | dark / black theme = { color_scheme = themes.light }
'Doom Peacock', -- nice | dark / black / vivid
'DWM rob (terminal.sexy)',
'duskfox',
'Elio (Gogh)', -- teh best so far | dark / blue
'Espresso', -- nice, but more on the average side | dark / black
'Espresso Libre',
'Fahrenheit', -- all the colors are wrong, but looks cool | dark / red
'FlatRemix (Gogh)', -- pretty cool | dark / vivid
'Galaxy', -- pretty nice | dark / blue
'Galizur', -- great and vivid | dark
'GJM (terminal.sexy)', -- nice vivid | dark
'Glacier', -- vivid, very dark
'gotham (Gogh)', -- surprisingly good, compared to the vim theme
'Gruvbox Dark',
'HemisuDark (Gogh)', -- vivid, but dark
'hund (terminal.sexy)', -- pretty well-balanced dark
'Japanesque', -- balanced, average, dark
'Material (terminal.sexy)', -- unusual combination, balanced
'Medallion', -- quite fun reddish theme, dark
'MonaLisa', -- impressively good, but very red and dark
'Parker Brothers (terminal.sexy)', -- unique but kinda dark
'PaulMillr', -- bright and clear
'PencilDark', -- very nice, matches PencilColors
'Rasi (terminal.sexy)', -- legitemately nice, yet dark
'Red Planet', -- dull, low contrast
'Rezza (terminal.sexy)', -- same
'SeaShells', -- wonderful colors, dark and vivid
'SleepyHollow', -- unusual colors
'Srcery (Gogh)', -- nice, but a bit too low on contrast
}
local default_theme = themes[18]
local webinar_overrides = {
harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' },
color_scheme = 'PencilLight',
} }
local current_overrides = {}
function switch_theme(number, window) local function get_os()
theme_n = theme_n + number local current_os = os.getenv('OS')
if theme_n < 1 then theme_n = #themes end if current_os then return current_os end
if theme_n > #themes then theme_n = 1 end return io.popen('uname -s', 'r'):read()
window:set_config_overrides { color_scheme = themes[theme_n] }
end end
function set_fontsize() local function set_fontsize(sizes)
local execfile = os.getenv('WEZTERM_EXECUTABLE') local my_os = get_os()
if string.match(execfile, 'MacOS') then return fontsize_darwin end if sizes[my_os] then return sizes[my_os] end
return fontsize_others return sizes.others
end end
wt.on('update-right-status', function(window, pane) local function toggle_overrides(window, overrides)
local theme_info = string.format( for k, v in pairs(overrides) do
'%s %s ', wt.nerdfonts.fa_terminal, if current_overrides[k] == v then
window:effective_config().color_scheme current_overrides[k] = nil
) else
window:set_right_status(wt.format {{ Text = theme_info }}) current_overrides[k] = v
end) end
wt.on('prev-theme', function(window) switch_theme(-1, window) end) end
wt.on('next-theme', function(window) switch_theme( 1, window) end) window:set_config_overrides(current_overrides)
wt.on('reset-overrides', function(window) window:set_config_overrides() end) end
wt.on('webinar', function(window) window:set_config_overrides(webinar_overrides) end)
local function reset_overrides(window)
current_overrides = {}
window:set_config_overrides()
end
wt.on('override-theme', function(window) toggle_overrides(window, overrides.theme) end)
wt.on('override-fonts', function(window) toggle_overrides(window, overrides.fonts) end)
wt.on('reset-overrides', function(window) reset_overrides(window) end)
return { return {
audible_bell = 'Disabled', audible_bell = 'Disabled',
font_size = set_fontsize(), font_size = set_fontsize(fontsizes),
font = wt.font 'Cascadia Code PL', font = wt.font(font),
harfbuzz_features = { 'ss01=1', 'ss19=1' }, harfbuzz_features = font_features,
color_scheme = default_theme, color_scheme = theme,
cursor_blink_rate = 0, cursor_blink_rate = 0,
check_for_updates = false, check_for_updates = false,
bold_brightens_ansi_colors = false, bold_brightens_ansi_colors = false,
@ -86,23 +60,22 @@ return {
{ key = 'c', mods = 'META', action = act.Copy }, { key = 'c', mods = 'META', action = act.Copy },
{ key = 'v', mods = 'META', action = act.Paste }, { key = 'v', mods = 'META', action = act.Paste },
-- themes -- themes
{ key = 'a', mods = 'META', action = act.EmitEvent 'prev-theme' }, { key = 'f', mods = 'LEADER', action = act.EmitEvent('override-fonts') },
{ key = 's', mods = 'META', action = act.EmitEvent 'next-theme' }, { key = 't', mods = 'LEADER', action = act.EmitEvent('override-theme') },
{ key = 'd', mods = 'META', action = act.EmitEvent 'reset-overrides' }, { key = 'r', mods = 'LEADER', action = act.EmitEvent('reset-overrides') },
{ key = 'w', mods = 'META', action = act.EmitEvent 'webinar' },
-- tabs -- tabs
{ key = 'c', mods = 'LEADER', action = act.SpawnTab 'DefaultDomain' }, { key = 'c', mods = 'LEADER', action = act.SpawnTab('DefaultDomain') },
{ key = 'n', mods = 'LEADER', action = act.ActivateTabRelative( 1) }, { key = 'n', mods = 'LEADER', action = act.ActivateTabRelative( 1) },
{ key = 'p', mods = 'LEADER', action = act.ActivateTabRelative(-1) }, { key = 'p', mods = 'LEADER', action = act.ActivateTabRelative(-1) },
-- panes -- panes
{ key = 's', mods = 'LEADER', action = act.SplitVertical { domain = 'CurrentPaneDomain' } }, { key = 's', mods = 'LEADER', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
{ key = 'v', mods = 'LEADER', action = act.SplitHorizontal{ domain = 'CurrentPaneDomain' } }, { key = 'v', mods = 'LEADER', action = act.SplitHorizontal{ domain = 'CurrentPaneDomain' } },
{ key = 'h', mods = 'LEADER', action = act.ActivatePaneDirection 'Left' }, { key = 'h', mods = 'LEADER', action = act.ActivatePaneDirection('Left') },
{ key = 'j', mods = 'LEADER', action = act.ActivatePaneDirection 'Down' }, { key = 'j', mods = 'LEADER', action = act.ActivatePaneDirection('Down') },
{ key = 'k', mods = 'LEADER', action = act.ActivatePaneDirection 'Up' }, { key = 'k', mods = 'LEADER', action = act.ActivatePaneDirection('Up') },
{ key = 'l', mods = 'LEADER', action = act.ActivatePaneDirection 'Right' }, { key = 'l', mods = 'LEADER', action = act.ActivatePaneDirection('Right') },
{ key = 'u', mods = 'LEADER', action = act.RotatePanes 'Clockwise' }, { key = 'u', mods = 'LEADER', action = act.RotatePanes('Clockwise') },
{ key = 'i', mods = 'LEADER', action = act.RotatePanes 'CounterClockwise' }, { key = 'i', mods = 'LEADER', action = act.RotatePanes('CounterClockwise') },
{ key = 'Return', mods = 'LEADER', action = act.TogglePaneZoomState }, { key = 'Return', mods = 'LEADER', action = act.TogglePaneZoomState },
{ key = 'Space', mods = 'LEADER', action = act.PaneSelect }, { key = 'Space', mods = 'LEADER', action = act.PaneSelect },
}, },