diff --git a/gui/.config/wezterm/functions.lua b/gui/.config/wezterm/functions.lua new file mode 100644 index 0000000..ced4746 --- /dev/null +++ b/gui/.config/wezterm/functions.lua @@ -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 +} diff --git a/gui/.config/wezterm/keybinds.lua b/gui/.config/wezterm/keybinds.lua new file mode 100644 index 0000000..14fe638 --- /dev/null +++ b/gui/.config/wezterm/keybinds.lua @@ -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 +} diff --git a/gui/.config/wezterm/overrides.lua b/gui/.config/wezterm/overrides.lua new file mode 100644 index 0000000..f56de7b --- /dev/null +++ b/gui/.config/wezterm/overrides.lua @@ -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) diff --git a/gui/.config/wezterm/wezterm.lua b/gui/.config/wezterm/wezterm.lua index 7874832..47a642e 100644 --- a/gui/.config/wezterm/wezterm.lua +++ b/gui/.config/wezterm/wezterm.lua @@ -1,8 +1,11 @@ +require('overrides') local wt = require('wezterm') +local fn = require('functions') +local keys = require('keybinds') 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.audible_bell = 'Disabled' cfg.font = wt.font('Fantasque Sans Mono') @@ -11,15 +14,9 @@ cfg.color_scheme = 'Solarized Light (Gogh)' cfg.cursor_blink_rate = 0 cfg.check_for_updates = false cfg.bold_brightens_ansi_colors = false - -local fontsizes = { Darwin = 15, others = 12 } -local overrides = { - fonts = { - font = wt.font('JetBrains Mono'), - font_size = 11, - harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' } - }, - theme = { color_scheme = 'GruvboxDark' } +cfg.font_size = fn.set_by_os{ + Darwin = 15, + others = 12 } local tab_bar_fg = '#657b83' 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