terminal.nix (6834B)
1 # modules/home/terminal.nix — kitty with DMMono Nerd Font and Rosé Pine (main). 2 # 3 # The six patched DMMono TTFs come from the dotfiles checkout (tools.nix links 4 # ~/git/daemon-sec-dotfiles/assets/fonts/nerd-fonts-dm-mono into 5 # ~/.local/share/fonts). The family has no Bold, so bold maps to Medium. 6 # 7 # Palette rule from the migration prompt: pine #31748f is a fill, never ink, 8 # so it must not sit in an ANSI foreground slot. The Rosé Pine terminal theme 9 # puts pine in the green slot; the substitute is PARKED for the owner's 10 # decision. Until then `ansiGreen` below carries foam, the colour the toolbox 11 # itself uses wherever pine would have been read as text (bin/install.sh). 12 # 13 # tmux-style keys (2026-10-08): ctrl+a is a prefix, like tmux's, with tabs as 14 # tmux windows and kitty windows as tmux panes: 15 # 16 # ctrl+a c new tab (cwd kept) ctrl+a - split below (pane) 17 # ctrl+a n / p next / previous tab ctrl+a | split right 18 # ctrl+a 1..9 tab N ctrl+a h j k l focus pane left/down/up/right 19 # ctrl+a , rename tab ctrl+a H J K L move pane 20 # ctrl+a & close tab ctrl+a o next pane 21 # ctrl+a x close pane ctrl+a z zoom pane (stack layout toggle) 22 # ctrl+a [ copy mode (scrollback in Neovim: v y, Enter, q) 23 # ctrl+a ] paste clipboard ctrl+a space next layout 24 # ctrl+a { } swap pane back / forth ctrl+a r reload kitty.conf 25 # ctrl+a u pick a URL (hints) ctrl+a f pick a path (hints) 26 # ctrl+a ctrl+a send a real ctrl+a to the shell (beginning-of-line) 27 # ctrl+a shift+arrows resize pane ctrl+a = reset pane sizes 28 # 29 # Copy mode is modules/home/kitty/scrollback.lua: the scrollback opens in a bare 30 # Neovim (no AstroNvim config) with colours, vi motions and search; y copies 31 # to the clipboard, Enter copies and leaves, q or Esc leaves. 32 { ... }: 33 { 34 flake.homeModules.terminal = 35 { pkgs, lib, ... }: 36 let 37 ansiGreen = "#9ccfd8"; # PARKED: ask before changing; see header 38 39 # kitty substitutes INPUT_LINE_NUMBER, CURSOR_LINE and CURSOR_COLUMN in the 40 # pager command; the Lua reads them from vim.g. 41 scrollbackPager = lib.concatStringsSep " " [ 42 "${pkgs.bash}/bin/bash -c" 43 "'exec ${pkgs.neovim}/bin/nvim 63<&0 0</dev/null" 44 "-u ${./kitty/scrollback.lua}" 45 "-c \"let g:kitty_input_line=INPUT_LINE_NUMBER\"" 46 "-c \"let g:kitty_cursor_line=CURSOR_LINE\"" 47 "-c \"let g:kitty_cursor_col=CURSOR_COLUMN\"'" 48 ]; 49 50 prefix = "ctrl+a"; 51 tabKeys = lib.listToAttrs (map (n: { 52 name = "${prefix}>${toString n}"; 53 value = "goto_tab ${toString n}"; 54 }) (lib.range 1 9)); 55 in 56 { 57 fonts.fontconfig.enable = true; 58 59 programs.kitty = { 60 enable = true; 61 font = { 62 name = "DMMono Nerd Font"; 63 size = 10; 64 }; 65 settings = { 66 bold_font = ''family="DMMono Nerd Font" style="Medium"''; 67 italic_font = ''family="DMMono Nerd Font" style="Italic"''; 68 bold_italic_font = ''family="DMMono Nerd Font" style="Medium Italic"''; 69 70 # Rosé Pine, main (dark) 71 foreground = "#e0def4"; 72 background = "#191724"; 73 selection_foreground = "#e0def4"; 74 selection_background = "#403d52"; # highlight med 75 cursor = "#524f67"; # highlight high 76 cursor_text_color = "#e0def4"; 77 url_color = "#c4a7e7"; 78 79 active_border_color = "#eb6f92"; 80 inactive_border_color = "#6e6a86"; 81 active_tab_foreground = "#e0def4"; 82 active_tab_background = "#26233a"; 83 inactive_tab_foreground = "#6e6a86"; 84 inactive_tab_background = "#191724"; 85 86 color0 = "#26233a"; 87 color8 = "#6e6a86"; 88 color1 = "#eb6f92"; 89 color9 = "#eb6f92"; 90 color2 = ansiGreen; 91 color10 = ansiGreen; 92 color3 = "#f6c177"; 93 color11 = "#f6c177"; 94 color4 = "#9ccfd8"; 95 color12 = "#9ccfd8"; 96 color5 = "#c4a7e7"; 97 color13 = "#c4a7e7"; 98 color6 = "#ebbcba"; 99 color14 = "#ebbcba"; 100 color7 = "#e0def4"; 101 color15 = "#e0def4"; 102 103 # tmux-like layout: panes via the splits layout, stack = zoom, tabs on a 104 # bottom status line with their index like tmux's window list. 105 enabled_layouts = "splits,stack"; 106 window_border_width = "1pt"; 107 inactive_text_alpha = "0.8"; 108 tab_bar_edge = "bottom"; 109 tab_bar_style = "powerline"; 110 tab_powerline_style = "slanted"; 111 tab_title_template = "{index}:{title}"; 112 active_tab_title_template = "{index}:{title}"; 113 scrollback_lines = 20000; 114 scrollback_pager = scrollbackPager; 115 shell_integration = "enabled"; 116 # Always zsh, whatever $SHELL the session was started with (a session 117 # begun before the login shell changed still carries SHELL=bash). 118 shell = "${pkgs.zsh}/bin/zsh"; 119 }; 120 121 keybindings = { 122 # tabs = tmux windows 123 "${prefix}>c" = "new_tab_with_cwd"; 124 "${prefix}>n" = "next_tab"; 125 "${prefix}>p" = "previous_tab"; 126 "${prefix}>," = "set_tab_title"; 127 "${prefix}>&" = "close_tab"; 128 "${prefix}>w" = "select_tab"; 129 # panes = kitty windows 130 "${prefix}>-" = "launch --location=hsplit --cwd=current"; 131 "${prefix}>|" = "launch --location=vsplit --cwd=current"; 132 "${prefix}>x" = "close_window"; 133 "${prefix}>o" = "next_window"; 134 "${prefix}>z" = "toggle_layout stack"; 135 "${prefix}>space" = "next_layout"; 136 "${prefix}>h" = "neighboring_window left"; 137 "${prefix}>j" = "neighboring_window down"; 138 "${prefix}>k" = "neighboring_window up"; 139 "${prefix}>l" = "neighboring_window right"; 140 "${prefix}>shift+h" = "move_window left"; 141 "${prefix}>shift+j" = "move_window down"; 142 "${prefix}>shift+k" = "move_window up"; 143 "${prefix}>shift+l" = "move_window right"; 144 "${prefix}>{" = "move_window_backward"; 145 "${prefix}>}" = "move_window_forward"; 146 "${prefix}>shift+left" = "resize_window narrower 3"; 147 "${prefix}>shift+right" = "resize_window wider 3"; 148 "${prefix}>shift+up" = "resize_window taller 3"; 149 "${prefix}>shift+down" = "resize_window shorter 3"; 150 "${prefix}>=" = "resize_window reset"; 151 # copy mode and paste 152 "${prefix}>[" = "show_scrollback"; 153 "${prefix}>]" = "paste_from_clipboard"; 154 "${prefix}>u" = "open_url_with_hints"; 155 "${prefix}>f" = "kitten hints --type path --program -"; 156 # misc 157 "${prefix}>r" = "load_config_file"; 158 "${prefix}>?" = "kitten show_key -m kitty"; 159 "${prefix}>${prefix}" = "send_text all \\x01"; 160 } // tabKeys; 161 }; 162 } 163 ; 164 }