Adds wezterm config as home manager module
This commit is contained in:
parent
98f4a6679e
commit
8d604f9278
9 changed files with 358 additions and 0 deletions
32
home/modules/wezterm/config/appearance.lua
Normal file
32
home/modules/wezterm/config/appearance.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
local wezterm = require("wezterm")
|
||||
local theme = wezterm.plugin.require("https://github.com/neapsix/wezterm").main
|
||||
local helpers = require("helpers")
|
||||
|
||||
local M = {}
|
||||
|
||||
local scheme = wezterm.get_builtin_color_schemes()["rose-pine"]
|
||||
|
||||
scheme.selection_fg = "white"
|
||||
scheme.selection_bg = "teal"
|
||||
scheme.copy_mode_active_highlight_bg = { AnsiColor = "Teal" }
|
||||
scheme.copy_mode_active_highlight_fg = { AnsiColor = "White" }
|
||||
scheme.copy_mode_inactive_highlight_bg = { AnsiColor = "Silver" }
|
||||
scheme.copy_mode_inactive_highlight_fg = { AnsiColor = "Black" }
|
||||
|
||||
function M.apply_to_config(config)
|
||||
config.color_schemes = {
|
||||
["rose-pine"] = scheme,
|
||||
}
|
||||
config.color_scheme = "rose-pine"
|
||||
config.font = wezterm.font("VictorMono Nerd Font", { weight = "DemiBold", stretch = "Normal", style = "Normal" })
|
||||
config.font_size = 18.5
|
||||
config.window_decorations = "RESIZE"
|
||||
config.window_padding = helpers.get_padding(20, 15)
|
||||
config.window_background_opacity = 0.97
|
||||
config.macos_window_background_blur = 30
|
||||
config.command_palette_font_size = 19
|
||||
config.command_palette_fg_color = theme.colors().foreground
|
||||
config.command_palette_bg_color = theme.colors().tab_bar.active_tab.bg_color
|
||||
end
|
||||
|
||||
return M
|
||||
55
home/modules/wezterm/config/helpers.lua
Normal file
55
home/modules/wezterm/config/helpers.lua
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
local wezterm = require("wezterm")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.project_dir()
|
||||
return wezterm.home_dir .. "/dev"
|
||||
end
|
||||
|
||||
function M.project_dirs()
|
||||
local projects = { wezterm.home_dir }
|
||||
|
||||
for _, dir in ipairs(wezterm.glob(M.project_dir() .. "/*")) do
|
||||
table.insert(projects, dir)
|
||||
end
|
||||
|
||||
return projects
|
||||
end
|
||||
|
||||
function M.get_outdated_packages()
|
||||
local success, stdout, stderr =
|
||||
wezterm.run_child_process({ "sh", "-c", "/opt/homebrew/bin/brew outdated -q | wc -l" })
|
||||
|
||||
if success ~= true then
|
||||
wezterm.log_error(stderr)
|
||||
|
||||
return "X"
|
||||
end
|
||||
|
||||
return stdout:gsub("%s+", "")
|
||||
end
|
||||
|
||||
function M.get_primary_battery_state()
|
||||
local battery_info = wezterm.battery_info()
|
||||
|
||||
return string.format("%.0f%%", battery_info[1].state_of_charge * 100)
|
||||
end
|
||||
|
||||
function M.get_padding(padding, remove_padding_bottom)
|
||||
return {
|
||||
left = padding,
|
||||
right = padding,
|
||||
top = padding,
|
||||
bottom = padding - remove_padding_bottom,
|
||||
}
|
||||
end
|
||||
|
||||
function M.move_pane(key, direction)
|
||||
return {
|
||||
key = key,
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.ActivatePaneDirection(direction),
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
88
home/modules/wezterm/config/keybindings.lua
Normal file
88
home/modules/wezterm/config/keybindings.lua
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
local wezterm = require("wezterm")
|
||||
local helpers = require("helpers")
|
||||
local projects = require("projects")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.apply_to_config(config)
|
||||
config.leader = { key = "b", mods = "CTRL", timeout_milliseconds = 1000 }
|
||||
|
||||
config.keys = {
|
||||
-- Window/Pane Management
|
||||
{
|
||||
key = "|",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.SplitHorizontal({ domain = "CurrentPaneDomain" }),
|
||||
},
|
||||
{
|
||||
key = "-",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.SplitVertical({ domain = "CurrentPaneDomain" }),
|
||||
},
|
||||
{
|
||||
key = "-",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.SplitVertical({ domain = "CurrentPaneDomain" }),
|
||||
},
|
||||
{
|
||||
key = "x",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.CloseCurrentPane({ confirm = true }),
|
||||
},
|
||||
{
|
||||
mods = "LEADER",
|
||||
key = "z",
|
||||
action = wezterm.action.TogglePaneZoomState,
|
||||
},
|
||||
{
|
||||
mods = "LEADER",
|
||||
key = "u",
|
||||
action = wezterm.action.PaneSelect({
|
||||
mode = "SwapWithActive",
|
||||
}),
|
||||
},
|
||||
-- Navigation
|
||||
helpers.move_pane("j", "Down"),
|
||||
helpers.move_pane("k", "Up"),
|
||||
helpers.move_pane("h", "Left"),
|
||||
helpers.move_pane("l", "Right"),
|
||||
-- Workspaces
|
||||
{
|
||||
key = "s",
|
||||
mods = "LEADER",
|
||||
action = projects.choose(),
|
||||
},
|
||||
{
|
||||
key = "w",
|
||||
mods = "LEADER",
|
||||
-- Present a list of existing workspaces
|
||||
action = wezterm.action.ShowLauncherArgs({ flags = "FUZZY|WORKSPACES" }),
|
||||
},
|
||||
-- Misc
|
||||
{
|
||||
key = " ",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.ActivateCommandPalette,
|
||||
},
|
||||
{
|
||||
key = "[",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.ActivateCopyMode,
|
||||
},
|
||||
{
|
||||
key = "c",
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.SpawnTab("CurrentPaneDomain"),
|
||||
},
|
||||
}
|
||||
|
||||
for i = 1, 8 do
|
||||
table.insert(config.keys, {
|
||||
key = tostring(i),
|
||||
mods = "LEADER",
|
||||
action = wezterm.action.ActivateTab(i - 1),
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
20
home/modules/wezterm/config/overrides.lua
Normal file
20
home/modules/wezterm/config/overrides.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
local wezterm = require("wezterm")
|
||||
local hn = wezterm.hostname()
|
||||
local helpers = require("helpers")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.apply_to_config(config)
|
||||
--if hn == "macbook.digital-h.de" then
|
||||
--end
|
||||
|
||||
if hn == "dnsc-desktop" then
|
||||
config.font = wezterm.font("Victor Mono", { weight = "DemiBold" })
|
||||
config.font_size = 14
|
||||
config.window_decorations = "RESIZE"
|
||||
config.window_padding = helpers.get_padding(18, 6)
|
||||
config.window_background_opacity = 1
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
33
home/modules/wezterm/config/projects.lua
Normal file
33
home/modules/wezterm/config/projects.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
local wezterm = require("wezterm")
|
||||
local helpers = require("helpers")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.choose()
|
||||
local choices = {}
|
||||
|
||||
for _, value in ipairs(helpers.project_dirs()) do
|
||||
table.insert(choices, { label = value })
|
||||
end
|
||||
|
||||
return wezterm.action.InputSelector({
|
||||
title = "Projects",
|
||||
choices = choices,
|
||||
fuzzy = true,
|
||||
action = wezterm.action_callback(function(child_window, child_pane, _, label)
|
||||
if not label then
|
||||
return
|
||||
end
|
||||
|
||||
child_window:perform_action(
|
||||
wezterm.action.SwitchToWorkspace({
|
||||
name = label:match("([^/]+)$"),
|
||||
spawn = { cwd = label },
|
||||
}),
|
||||
child_pane
|
||||
)
|
||||
end),
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
60
home/modules/wezterm/config/startup.lua
Normal file
60
home/modules/wezterm/config/startup.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
local wezterm = require("wezterm")
|
||||
local mux = wezterm.mux
|
||||
local helpers = require("helpers")
|
||||
|
||||
local M = {}
|
||||
|
||||
wezterm.on("gui-startup", function(cmd)
|
||||
local args = {}
|
||||
if cmd then
|
||||
args = cmd.args
|
||||
end
|
||||
|
||||
-- WORKSPACES
|
||||
-- W: dennis
|
||||
local _, _, _ = mux.spawn_window({
|
||||
workspace = "dennis",
|
||||
cwd = wezterm.home_dir,
|
||||
args = args,
|
||||
})
|
||||
|
||||
-- W: dnsc-v2
|
||||
local dnsc_v2_root = helpers.project_dir() .. "/dnsc-v2"
|
||||
local _, dnsc_v2_root_pane, _ = mux.spawn_window({
|
||||
workspace = "dnsc-v2",
|
||||
cwd = dnsc_v2_root,
|
||||
args = args,
|
||||
})
|
||||
|
||||
local _ = dnsc_v2_root_pane:split({
|
||||
direction = "Left",
|
||||
size = 0.7,
|
||||
cwd = dnsc_v2_root,
|
||||
})
|
||||
|
||||
-- dnsc_v2_root_pane:send_text("npm run dev\n")
|
||||
|
||||
-- W: freed
|
||||
local freed_root = helpers.project_dir() .. "/freed"
|
||||
local _, freed_root_pane, _ = mux.spawn_window({
|
||||
workspace = "freed",
|
||||
cwd = freed_root,
|
||||
args = args,
|
||||
})
|
||||
|
||||
local _ = freed_root_pane:split({
|
||||
direction = "Left",
|
||||
size = 0.7,
|
||||
cwd = freed_root,
|
||||
})
|
||||
|
||||
-- freed_root_pane:send_text("air\n")
|
||||
|
||||
mux.set_active_workspace("dennis")
|
||||
end)
|
||||
|
||||
function M.apply_to_config(config)
|
||||
return config
|
||||
end
|
||||
|
||||
return M
|
||||
40
home/modules/wezterm/config/tab_bar.lua
Normal file
40
home/modules/wezterm/config/tab_bar.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
local wezterm = require("wezterm")
|
||||
local theme = wezterm.plugin.require("https://github.com/neapsix/wezterm").main
|
||||
local helpers = require("helpers")
|
||||
|
||||
local M = {}
|
||||
|
||||
local function get_elements(for_window)
|
||||
return {
|
||||
{ Background = { Color = theme.colors().tab_bar.background } },
|
||||
{ Foreground = { Color = theme.colors().tab_bar.inactive_tab.fg_color } },
|
||||
{ Text = "h:" .. wezterm.hostname() .. " " },
|
||||
{ Text = "upgrades:" .. helpers.get_outdated_packages() .. " " },
|
||||
{ Text = "bat:" .. helpers.get_primary_battery_state() .. " " },
|
||||
{ Background = { Color = theme.colors().tab_bar.active_tab.bg_color } },
|
||||
{ Foreground = { Color = theme.colors().tab_bar.active_tab.fg_color } },
|
||||
{ Text = " session >> " .. for_window:active_workspace() .. " " },
|
||||
}
|
||||
end
|
||||
|
||||
wezterm.on("update-right-status", function(window, _)
|
||||
window:set_right_status(wezterm.format(get_elements(window)))
|
||||
end)
|
||||
|
||||
function M.apply_to_config(config)
|
||||
config.enable_tab_bar = true
|
||||
config.use_fancy_tab_bar = true
|
||||
config.tab_bar_at_bottom = false
|
||||
|
||||
config.window_frame = {
|
||||
inactive_titlebar_bg = theme.colors().tab_bar.background,
|
||||
active_titlebar_bg = theme.colors().tab_bar.background,
|
||||
font = wezterm.font({ family = "Victor Mono", weight = "Bold" }),
|
||||
}
|
||||
|
||||
config.colors = {
|
||||
tab_bar = theme.colors().tab_bar,
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
21
home/modules/wezterm/config/wezterm.lua
Normal file
21
home/modules/wezterm/config/wezterm.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
local wezterm = require("wezterm")
|
||||
local appearance = require("appearance")
|
||||
local tab_bar = require("tab_bar")
|
||||
local startup = require("startup")
|
||||
local keybindings = require("keybindings")
|
||||
local overrides = require("overrides")
|
||||
|
||||
local config = {}
|
||||
|
||||
if wezterm.config_builder then
|
||||
---@diagnostic disable-next-line: lowercase-global
|
||||
config = wezterm.config_builder()
|
||||
end
|
||||
|
||||
appearance.apply_to_config(config)
|
||||
tab_bar.apply_to_config(config)
|
||||
startup.apply_to_config(config)
|
||||
keybindings.apply_to_config(config)
|
||||
overrides.apply_to_config(config)
|
||||
|
||||
return config
|
||||
9
home/modules/wezterm/default.nix
Normal file
9
home/modules/wezterm/default.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
programs.wezterm = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
home.file.".config/wezterm" = {
|
||||
source = ./config;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue