# modules/home/terminal.nix — kitty and Alacritty with DMMono Nerd Font and # Rosé Pine (main). # # Kitty is the default terminal (SUPER+Return). Alacritty is installed for tmux # work: every Alacritty window opens inside tmux (~/.tmux.conf, plugins in # shell.nix), so sessions, logging and scrollback live in tmux and survive the # window. A new window re-attaches the first detached session (an engagement # left running) or starts a fresh one; `alacritty -e zsh` gives a bare shell. # TERM stays xterm-256color: shells and ssh on targets have its terminfo, # rarely alacritty's. Hints (ctrl+shift+…) copy what is on screen: # ctrl+shift+u URL (opens) ctrl+shift+i IPv4 / IPv4:port # ctrl+shift+h hex hash ctrl+shift+p path # # The six patched DMMono TTFs come from this repo (dotfiles.nix links # dotfiles/assets/fonts/nerd-fonts-dm-mono into # ~/.local/share/fonts). The family has no Bold, so bold maps to Medium. # # Colours follow ../../theme.nix. Rosé Pine keeps foam in its ANSI green # slot for readability; Gruvpine uses Gruvbox's bright sage green. # # tmux-style keys (2026-10-08): ctrl+a is a prefix, like tmux's, with tabs as # tmux windows and kitty windows as tmux panes: # # ctrl+a c new tab (cwd kept) ctrl+a - split below (pane) # ctrl+a n / p next / previous tab ctrl+a | split right # ctrl+a 1..9 tab N ctrl+a h j k l focus pane left/down/up/right # ctrl+a , rename tab ctrl+a H J K L move pane # ctrl+a & close tab ctrl+a o next pane # ctrl+a x close pane ctrl+a z zoom pane (stack layout toggle) # ctrl+a [ copy mode (scrollback in Neovim: v y, Enter, q) # ctrl+a ] paste clipboard ctrl+a space next layout # ctrl+a { } swap pane back / forth ctrl+a r reload kitty.conf # ctrl+a u pick a URL (hints) ctrl+a f pick a path (hints) # ctrl+a ctrl+a send a real ctrl+a to the shell (beginning-of-line) # ctrl+a shift+arrows resize pane ctrl+a = reset pane sizes # # Copy mode is modules/home/kitty/scrollback.lua: the scrollback opens in a bare # Neovim (no AstroNvim config) with colours, vi motions and search; y copies # to the clipboard, Enter copies and leaves, q or Esc leaves. { ... }: let theme = import ../_palette.nix; in { flake.homeModules.terminal = { pkgs, lib, ... }: let ansiGreen = if theme.name != "rose-pine" then theme.palette.pine else theme.palette.foam; # kitty substitutes INPUT_LINE_NUMBER, CURSOR_LINE and CURSOR_COLUMN in the # pager command; the Lua reads them from vim.g. scrollbackPager = lib.concatStringsSep " " [ "${pkgs.bash}/bin/bash -c" "'exec ${pkgs.neovim}/bin/nvim 63<&0 0/dev/null | head -n1) if [ -n "$session" ]; then exec $tmux attach-session -t "=$session"; fi exec $tmux new-session ''; esc = builtins.fromJSON ''"\u001b"''; # Nix strings have no \u escape copyHint = key: regex: { inherit regex; action = "Copy"; post_processing = true; binding = { inherit key; mods = "Control|Shift"; }; }; tabKeys = lib.listToAttrs (map (n: { name = "${prefix}>${toString n}"; value = "goto_tab ${toString n}"; }) (lib.range 1 9)); in { fonts.fontconfig.enable = true; programs.kitty = { enable = true; font = { name = "DMMono Nerd Font"; size = 10; }; settings = { bold_font = ''family="DMMono Nerd Font" style="Medium"''; italic_font = ''family="DMMono Nerd Font" style="Italic"''; bold_italic_font = ''family="DMMono Nerd Font" style="Medium Italic"''; # Shared dark palette foreground = theme.palette.text; background = theme.palette.base; selection_foreground = theme.palette.text; selection_background = theme.palette.hlMed; # highlight med cursor = theme.palette.hlHigh; # highlight high cursor_text_color = theme.palette.text; url_color = theme.palette.iris; active_border_color = theme.palette.love; inactive_border_color = theme.palette.muted; active_tab_foreground = theme.palette.text; active_tab_background = theme.palette.overlay; inactive_tab_foreground = theme.palette.muted; inactive_tab_background = theme.palette.base; color0 = theme.palette.overlay; color8 = theme.palette.muted; color1 = theme.palette.love; color9 = theme.palette.love; color2 = ansiGreen; color10 = ansiGreen; color3 = theme.palette.gold; color11 = theme.palette.gold; color4 = theme.palette.foam; color12 = theme.palette.foam; color5 = theme.palette.iris; color13 = theme.palette.iris; color6 = theme.palette.rose; color14 = theme.palette.rose; color7 = theme.palette.text; color15 = theme.palette.text; # tmux-like layout: panes via the splits layout, stack = zoom, tabs on a # bottom status line with their index like tmux's window list. enabled_layouts = "splits,stack"; window_border_width = "1pt"; inactive_text_alpha = "0.8"; tab_bar_edge = "bottom"; tab_bar_style = "powerline"; tab_powerline_style = "slanted"; tab_title_template = "{index}:{title}"; active_tab_title_template = "{index}:{title}"; scrollback_lines = 20000; scrollback_pager = scrollbackPager; shell_integration = "enabled"; # Always zsh, whatever $SHELL the session was started with (a session # begun before the login shell changed still carries SHELL=bash). shell = "${pkgs.zsh}/bin/zsh"; }; keybindings = { # tabs = tmux windows "${prefix}>c" = "new_tab_with_cwd"; "${prefix}>n" = "next_tab"; "${prefix}>p" = "previous_tab"; "${prefix}>," = "set_tab_title"; "${prefix}>&" = "close_tab"; "${prefix}>w" = "select_tab"; # panes = kitty windows "${prefix}>-" = "launch --location=hsplit --cwd=current"; "${prefix}>|" = "launch --location=vsplit --cwd=current"; "${prefix}>x" = "close_window"; "${prefix}>o" = "next_window"; "${prefix}>z" = "toggle_layout stack"; "${prefix}>space" = "next_layout"; "${prefix}>h" = "neighboring_window left"; "${prefix}>j" = "neighboring_window down"; "${prefix}>k" = "neighboring_window up"; "${prefix}>l" = "neighboring_window right"; "${prefix}>shift+h" = "move_window left"; "${prefix}>shift+j" = "move_window down"; "${prefix}>shift+k" = "move_window up"; "${prefix}>shift+l" = "move_window right"; "${prefix}>{" = "move_window_backward"; "${prefix}>}" = "move_window_forward"; "${prefix}>shift+left" = "resize_window narrower 3"; "${prefix}>shift+right" = "resize_window wider 3"; "${prefix}>shift+up" = "resize_window taller 3"; "${prefix}>shift+down" = "resize_window shorter 3"; "${prefix}>=" = "resize_window reset"; # copy mode and paste "${prefix}>[" = "show_scrollback"; "${prefix}>]" = "paste_from_clipboard"; "${prefix}>u" = "open_url_with_hints"; "${prefix}>f" = "kitten hints --type path --program -"; # misc "${prefix}>r" = "load_config_file"; "${prefix}>?" = "kitten show_key -m kitty"; "${prefix}>${prefix}" = "send_text all \\x01"; } // tabKeys; }; programs.alacritty = { enable = true; settings = { env.TERM = "xterm-256color"; terminal = { shell.program = "${tmuxAttach}"; osc52 = "CopyPaste"; }; general.live_config_reload = true; window = { padding = { x = 14; y = 14; }; decorations = "None"; dynamic_title = true; }; scrolling.history = 100000; selection.save_to_clipboard = false; mouse.hide_when_typing = true; cursor.style = { shape = "Block"; blinking = "Off"; }; font = { normal = { family = "DMMono Nerd Font"; style = "Regular"; }; bold = { family = "DMMono Nerd Font"; style = "Medium"; }; italic = { family = "DMMono Nerd Font"; style = "Italic"; }; bold_italic = { family = "DMMono Nerd Font"; style = "Medium Italic"; }; size = 10; }; colors = { primary = { foreground = theme.palette.text; background = theme.palette.base; }; cursor = { cursor = theme.palette.hlHigh; text = theme.palette.text; }; vi_mode_cursor = { cursor = theme.palette.iris; text = theme.palette.base; }; selection = { background = theme.palette.hlMed; text = theme.palette.text; }; search = { matches = { foreground = theme.palette.base; background = theme.palette.gold; }; focused_match = { foreground = theme.palette.base; background = theme.palette.love; }; }; hints = { start = { foreground = theme.palette.base; background = theme.palette.gold; }; end = { foreground = theme.palette.base; background = theme.palette.foam; }; }; # Same ANSI mapping as kitty above. normal = { black = theme.palette.overlay; red = theme.palette.love; green = ansiGreen; yellow = theme.palette.gold; blue = theme.palette.foam; magenta = theme.palette.iris; cyan = theme.palette.rose; white = theme.palette.text; }; bright = { black = theme.palette.muted; red = theme.palette.love; green = ansiGreen; yellow = theme.palette.gold; blue = theme.palette.foam; magenta = theme.palette.iris; cyan = theme.palette.rose; white = theme.palette.text; }; }; hints.enabled = [ { regex = "(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://)[^\\x00-\\x1F\\x7F-\\x9F<>\"\\s{-}\\^⟨⟩`]+"; hyperlinks = true; command = "xdg-open"; post_processing = true; mouse.enabled = true; binding = { key = "U"; mods = "Control|Shift"; }; } (copyHint "I" "\\b(?:\\d{1,3}\\.){3}\\d{1,3}(?::\\d{1,5})?\\b") (copyHint "H" "\\b[0-9a-fA-F]{32,128}\\b") (copyHint "P" "(?:~|\\.{1,2})?/[\\w.@%+~-]+(?:/[\\w.@%+~-]+)*") ]; keyboard.bindings = [ { key = "Insert"; mods = "Shift"; action = "Paste"; } { key = "Insert"; mods = "Control"; action = "Copy"; } # Shift+Return as CSI-u so TUIs can tell it from Return without # reading it as Alt+Return. { key = "Return"; mods = "Shift"; chars = "${esc}[13;2u"; } # Legacy encoding sends Alt+Shift+Return as Alt+Return; CSI-u lets tmux # match M-S-Enter. { key = "Return"; mods = "Alt|Shift"; chars = "${esc}[13;4u"; } { key = "N"; mods = "Control|Shift"; action = "CreateNewWindow"; } ]; }; }; } ; }