grace/dots

dotfiles/nix configs

git clone https://git.gae.moe/grace/dots

Grace Yoderflake rewrite + a bunch\ni keep holding onto changes forever this is not how you use vcs08de973

main
3.2 KiB87 linesraw
1{ config, pkgs, ... }:
2
3{
4  xdg.configFile."wezterm/picker.fish".source = ../fish/wezterm-picker.fish;
5
6  programs.wezterm = {
7    enable = true;
8    extraConfig = ''
9      local act = wezterm.action
10      local config = wezterm.config_builder()
11
12      config.color_scheme = 'rose-pine'
13      config.font = wezterm.font('ComicCode Nerd Font', { weight = 'DemiBold' })
14      config.harfbuzz_features = { 'calt=0', 'liga=0', 'dlig=0' }
15      config.send_composed_key_when_left_alt_is_pressed = false
16      config.use_fancy_tab_bar = true
17      config.default_workspace = 'local'
18
19      config.unix_domains = { { name = 'unix' } }
20      config.default_domain = 'unix'
21      config.default_gui_startup_args = { 'connect', 'unix' }
22      local ssh_domains = wezterm.default_ssh_domains()
23      for i = 5, 15 do
24        local host = string.format('borg%02d', i)
25        table.insert(ssh_domains, {
26          name = 'SSH:' .. host,
27          remote_address = host .. '.cs',
28          multiplexing = 'None',
29        })
30      end
31      config.ssh_domains = ssh_domains
32
33      local picker = wezterm.action_callback(function(window, pane)
34        local args = { '${pkgs.fish}/bin/fish', '${config.xdg.configHome}/wezterm/picker.fish' }
35        for _, name in ipairs(wezterm.mux.get_workspace_names()) do
36          table.insert(args, 'workspace\t' .. name)
37        end
38        for _, domain in ipairs(ssh_domains) do
39          if domain.name:match('^SSH:') then
40            table.insert(args, 'ssh\t' .. domain.name:sub(5) .. '\t' .. domain.remote_address)
41          end
42        end
43        window:perform_action(act.SpawnCommandInNewTab {
44          domain = { DomainName = 'unix' },
45          args = args,
46        }, pane)
47      end)
48
49      wezterm.on('user-var-changed', function(window, pane, name, value)
50        if name ~= 'workspace_picker' then return end
51        local target = wezterm.json_parse(value)
52        window:perform_action(act.SwitchToWorkspace {
53          name = target.name,
54          spawn = {
55            domain = { DomainName = 'unix' },
56            cwd = target.cwd ~= "" and target.cwd or nil,
57            args = target.host ~= "" and { '${pkgs.openssh}/bin/ssh', target.host } or nil,
58          },
59        }, pane)
60        window:perform_action(act.CloseCurrentPane { confirm = false }, pane)
61      end)
62
63      local rename_workspace = act.PromptInputLine {
64        description = 'New workspace name',
65        action = wezterm.action_callback(function(window, pane, line)
66          if not line or line == "" then return end
67          wezterm.mux.rename_workspace(window:active_workspace(), line)
68        end),
69      }
70
71      config.keys = {
72        { key = 'V', mods = 'CTRL|SHIFT', action = act.SplitHorizontal { domain = 'CurrentPaneDomain' } },
73        { key = 'H', mods = 'CTRL|SHIFT', action = act.SplitVertical { domain = 'CurrentPaneDomain' } },
74        { key = 'p', mods = 'SUPER', action = picker },
75        { key = 'R', mods = 'SUPER|SHIFT', action = rename_workspace },
76      }
77
78      wezterm.on('update-right-status', function(window, pane)
79        local ok, domain = pcall(function() return pane:get_domain_name() end)
80        if not ok then return end
81        window:set_right_status(window:active_workspace() .. ' | ' .. domain)
82      end)
83
84      return config
85    '';
86  };
87}