wezterm: config restructure
This commit is contained in:
parent
edccffb4d6
commit
970436c17c
4 changed files with 92 additions and 79 deletions
16
gui/.config/wezterm/functions.lua
Normal file
16
gui/.config/wezterm/functions.lua
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
local function get_os()
|
||||||
|
local current_os = os.getenv('OS')
|
||||||
|
if current_os then return current_os end
|
||||||
|
return io.popen('uname -s', 'r'):read()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_by_os(values)
|
||||||
|
local my_os = get_os()
|
||||||
|
if values[my_os] then return values[my_os] end
|
||||||
|
return values.others
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
set_by_os = set_by_os
|
||||||
|
-- toggle_overrides = toggle_overrides
|
||||||
|
}
|
37
gui/.config/wezterm/keybinds.lua
Normal file
37
gui/.config/wezterm/keybinds.lua
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
local act = require('wezterm').action
|
||||||
|
|
||||||
|
local leader_key = { key = 'g', mods = 'CTRL', timeout_milliseconds = 1000 }
|
||||||
|
local keybinds = {
|
||||||
|
{ key = 'c', mods = 'META', action = act.CopyTo('Clipboard') },
|
||||||
|
{ key = 'v', mods = 'META', action = act.PasteFrom('Clipboard') },
|
||||||
|
-- themes
|
||||||
|
{ key = 'f', mods = 'LEADER', action = act.EmitEvent('override-fonts') },
|
||||||
|
{ key = 't', mods = 'LEADER', action = act.EmitEvent('override-theme') },
|
||||||
|
{ key = 'r', mods = 'LEADER', action = act.EmitEvent('override-reset') },
|
||||||
|
-- tabs
|
||||||
|
{ key = 'c', mods = 'LEADER', action = act.SpawnTab('DefaultDomain') },
|
||||||
|
{ key = 'n', mods = 'LEADER', action = act.ActivateTabRelative( 1) },
|
||||||
|
{ key = 'p', mods = 'LEADER', action = act.ActivateTabRelative(-1) },
|
||||||
|
-- panes
|
||||||
|
{ key = 's', mods = 'LEADER', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
|
||||||
|
{ key = 'v', mods = 'LEADER', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } },
|
||||||
|
{ 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 = 'u', mods = 'LEADER', action = act.RotatePanes('Clockwise') },
|
||||||
|
{ key = 'i', mods = 'LEADER', action = act.RotatePanes('CounterClockwise') },
|
||||||
|
{ key = 'Return', mods = 'LEADER', action = act.TogglePaneZoomState },
|
||||||
|
{ key = 'Space', mods = 'LEADER', action = act.PaneSelect },
|
||||||
|
}
|
||||||
|
for i = 1, 9 do
|
||||||
|
table.insert(
|
||||||
|
keybinds,
|
||||||
|
{ key = tostring(i), mods = 'LEADER', action = act.ActivateTab(i - 1) }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
leader = leader_key,
|
||||||
|
keybinds = keybinds
|
||||||
|
}
|
31
gui/.config/wezterm/overrides.lua
Normal file
31
gui/.config/wezterm/overrides.lua
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
local wt = require('wezterm')
|
||||||
|
|
||||||
|
local current = {}
|
||||||
|
local overrides = {
|
||||||
|
fonts = {
|
||||||
|
font = wt.font('JetBrains Mono'),
|
||||||
|
font_size = 11,
|
||||||
|
harfbuzz_features = {'calt=0', 'clig=0', 'liga=0'}
|
||||||
|
},
|
||||||
|
theme = {color_scheme = 'GruvboxDark'}
|
||||||
|
}
|
||||||
|
|
||||||
|
local function toggle_overrides(window, overrides)
|
||||||
|
for k, v in pairs(overrides) do
|
||||||
|
if current[k] == v then
|
||||||
|
current[k] = nil
|
||||||
|
else
|
||||||
|
current[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
window:set_config_overrides(current)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function reset_overrides(window)
|
||||||
|
window:set_config_overrides()
|
||||||
|
current = {}
|
||||||
|
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('override-reset', reset_overrides)
|
|
@ -1,8 +1,11 @@
|
||||||
|
require('overrides')
|
||||||
local wt = require('wezterm')
|
local wt = require('wezterm')
|
||||||
|
local fn = require('functions')
|
||||||
|
local keys = require('keybinds')
|
||||||
local cfg = wt.config_builder()
|
local cfg = wt.config_builder()
|
||||||
local act = wt.action
|
|
||||||
local current_overrides = {}
|
|
||||||
|
|
||||||
|
cfg.leader = keys.leader
|
||||||
|
cfg.keys = keys.keybinds
|
||||||
cfg.xcursor_theme = 'Adwaita'
|
cfg.xcursor_theme = 'Adwaita'
|
||||||
cfg.audible_bell = 'Disabled'
|
cfg.audible_bell = 'Disabled'
|
||||||
cfg.font = wt.font('Fantasque Sans Mono')
|
cfg.font = wt.font('Fantasque Sans Mono')
|
||||||
|
@ -11,15 +14,9 @@ cfg.color_scheme = 'Solarized Light (Gogh)'
|
||||||
cfg.cursor_blink_rate = 0
|
cfg.cursor_blink_rate = 0
|
||||||
cfg.check_for_updates = false
|
cfg.check_for_updates = false
|
||||||
cfg.bold_brightens_ansi_colors = false
|
cfg.bold_brightens_ansi_colors = false
|
||||||
|
cfg.font_size = fn.set_by_os{
|
||||||
local fontsizes = { Darwin = 15, others = 12 }
|
Darwin = 15,
|
||||||
local overrides = {
|
others = 12
|
||||||
fonts = {
|
|
||||||
font = wt.font('JetBrains Mono'),
|
|
||||||
font_size = 11,
|
|
||||||
harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' }
|
|
||||||
},
|
|
||||||
theme = { color_scheme = 'GruvboxDark' }
|
|
||||||
}
|
}
|
||||||
local tab_bar_fg = '#657b83'
|
local tab_bar_fg = '#657b83'
|
||||||
local tab_bar_bg = '#eee8d5'
|
local tab_bar_bg = '#eee8d5'
|
||||||
|
@ -55,72 +52,4 @@ cfg.colors = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local leader_key = { key = 'g', mods = 'CTRL', timeout_milliseconds = 1000 }
|
|
||||||
local keybinds = {
|
|
||||||
{ key = 'c', mods = 'META', action = act.CopyTo('Clipboard') },
|
|
||||||
{ key = 'v', mods = 'META', action = act.PasteFrom('Clipboard') },
|
|
||||||
-- themes
|
|
||||||
{ key = 'f', mods = 'LEADER', action = act.EmitEvent('override-fonts') },
|
|
||||||
{ key = 't', mods = 'LEADER', action = act.EmitEvent('override-theme') },
|
|
||||||
{ key = 'r', mods = 'LEADER', action = act.EmitEvent('override-reset') },
|
|
||||||
-- tabs
|
|
||||||
{ key = 'c', mods = 'LEADER', action = act.SpawnTab('DefaultDomain') },
|
|
||||||
{ key = 'n', mods = 'LEADER', action = act.ActivateTabRelative( 1) },
|
|
||||||
{ key = 'p', mods = 'LEADER', action = act.ActivateTabRelative(-1) },
|
|
||||||
-- panes
|
|
||||||
{ key = 's', mods = 'LEADER', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
|
|
||||||
{ key = 'v', mods = 'LEADER', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } },
|
|
||||||
{ 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 = 'u', mods = 'LEADER', action = act.RotatePanes('Clockwise') },
|
|
||||||
{ key = 'i', mods = 'LEADER', action = act.RotatePanes('CounterClockwise') },
|
|
||||||
{ key = 'Return', mods = 'LEADER', action = act.TogglePaneZoomState },
|
|
||||||
{ key = 'Space', mods = 'LEADER', action = act.PaneSelect },
|
|
||||||
}
|
|
||||||
for i = 1, 9 do
|
|
||||||
table.insert(
|
|
||||||
keybinds,
|
|
||||||
{ key = tostring(i), mods = 'LEADER', action = act.ActivateTab(i - 1) }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
cfg.leader = leader_key
|
|
||||||
cfg.keys = keybinds
|
|
||||||
|
|
||||||
local function get_os()
|
|
||||||
local current_os = os.getenv('OS')
|
|
||||||
if current_os then return current_os end
|
|
||||||
return io.popen('uname -s', 'r'):read()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function set_by_os(values)
|
|
||||||
local my_os = get_os()
|
|
||||||
if values[my_os] then return values[my_os] end
|
|
||||||
return values.others
|
|
||||||
end
|
|
||||||
|
|
||||||
local function toggle_overrides(window, overrides)
|
|
||||||
for k, v in pairs(overrides) do
|
|
||||||
if current_overrides[k] == v then
|
|
||||||
current_overrides[k] = nil
|
|
||||||
else
|
|
||||||
current_overrides[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
window:set_config_overrides(current_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('override-reset', reset_overrides)
|
|
||||||
|
|
||||||
cfg.font_size = set_by_os(fontsizes)
|
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
|
|
Loading…
Reference in a new issue