{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.local.apps.terminal;
in {
  options.local.apps.terminal.enable = mkEnableOption "terminal emulator settings";
  config = mkIf cfg.enable {
    programs = {
      foot = {
        enable = true;
        settings = {
          main = {
            term = "xterm-256color";
            font = "JetBrains Mono:style=Medium:size=15";
            font-bold = "JetBrains Mono:style=Bold:size=15";
            font-italic = "JetBrains Mono:style=Italic:size=15";
            font-bold-italic = "JetBrains Mono:style=Bold Italic:size=15";
            dpi-aware = "yes";
            initial-window-size-pixels = "1200x600";
          };

          cursor = {
            style = "block";
            blink = "yes";
          };

          colors = {
            background = "000000";
            regular0 = "616161";
            regular1 = "ff4d51";
            regular2 = "35d450";
            regular3 = "e9e836";
            regular4 = "5dc5f8";
            regular5 = "feabf2";
            regular6 = "24dfc4";
            regular7 = "ffffff";
          };

          bell = {
            system = "no";
            urgent = "no";
            notify = "no";
            visual = "no";
            command-focused = "no";
          };

          mouse = {
            hide-when-typing = "no";
          };

          key-bindings = {
            clipboard-copy = "Control+Shift+c";
            clipboard-paste = "Control+Shift+v";
            font-increase = "Control+Shift+equal";
            font-decrease = "Control+Shift+minus";
            font-reset = "Control+Shift+BackSpace";
          };

          mouse-bindings = {
            scrollback-up-mouse = "BTN_WHEEL_BACK";
            scrollback-down-mouse = "BTN_WHEEL_FORWARD";
            font-increase = "Control+BTN_WHEEL_BACK";
            font-decrease = "Control+BTN_WHEEL_FORWARD";
            select-begin = "BTN_LEFT";
            select-begin-block = "Control+BTN_LEFT";
            select-extend = "BTN_RIGHT";
            select-extend-character-wise = "Control+BTN_RIGHT";
            select-word = "BTN_LEFT-2";
            select-word-whitespace = "Control+BTN_LEFT-2";
            select-quote = " BTN_LEFT-3";
            select-row = "BTN_LEFT-4";
          };
        };
      };

      tmux = {
        enable = true;
        aggressiveResize = true;
        clock24 = true;
        escapeTime = 10;
        terminal = "xterm-256color";
        keyMode = "emacs";
        mouse = true;

        extraConfig = ''
          set -ga update-environment " LIFT_PID"
          set -g set-titles on
          set -g renumber-windows on
          set -sa terminal-overrides ',xterm-termite:RGB'

          set -g status-style bg=default,fg=colour250
          set -g pane-border-style fg=colour236
          set -g pane-active-border-style fg=colour240
          set -g window-status-format " #I:#W "
          set -g window-status-style bg=default,fg=colour244
          set -g window-status-current-format " #I:#W "
          set -g window-status-current-style bg=colour236,fg=white,bold
          set -g status-position bottom
          set -g status-left-length 20
          set -g status-right-length 60
          set -g status-left ""
          set -g window-status-separator ""
          set -g status-justify left
        '';
      };
    };
    home = {
      sessionVariables = {
        "TERMINAL" = "foot";
      };
    };
  };
}
