{ config, pkgs, lib, ... }: let # OneDark palette kitty-theme = "One Dark"; palette-bg0 = "#282c34"; palette-bg1 = "#31353f"; palette-bg2 = "#393f4a"; palette-bg3 = "#3b3f4c"; palette-red = "#e06c75"; palette-green = "#98c379"; palette-yellow = "#e5c07b"; palette-blue = "#61afef"; palette-purple = "#c678dd"; palette-cyan = "#56b6c2"; palette-fg0 = "#abb2bf"; # Tab name generator name-list = pkgs.fetchzip { url = "https://gist.github.com/fenkint1/d9482a96c05b973354ce36f0872770f9/archive/0e75d4a0a2751270dd0d661707ead87a148e29bf.zip"; hash = "sha256-ILKW77r0HZKnlIdjH+6iMNOmKLocFZ2chjmUtDt8PhI="; } + "/pokemon_names.txt"; name-rnd = pkgs.writeShellApplication { name = "set-rnd-tab-title"; text = '' kitten @ set-tab-title "$(shuf -n 1 ${name-list} | tr '[:upper:]' '[:lower:]')" ''; }; in { home.sessionVariables.TERMINAL = lib.mkDefault "${pkgs.kitty}/bin/kitty"; home.packages = with pkgs; [ termpdfpy ]; programs.kitty = { enable = true; font = { name = "monospace"; size = lib.mkDefault 10; }; shellIntegration = { enableBashIntegration = true; mode = "no-title"; }; theme = kitty-theme; keybindings = let leader = "ctrl+space"; in { # Windows "${leader}>w>q" = "close_window"; "${leader}>w>w" = "launch --location=split"; "${leader}>w>s" = "launch --location=hsplit"; "${leader}>w>v" = "launch --location=vsplit"; "${leader}>h" = "neighboring_window left"; "${leader}>j" = "neighboring_window down"; "${leader}>k" = "neighboring_window up"; "${leader}>l" = "neighboring_window right"; "${leader}>shift+h" = "move_window left"; "${leader}>shift+j" = "move_window down"; "${leader}>shift+k" = "move_window up"; "${leader}>shift+l" = "move_window right"; # Tabs "${leader}>t>t" = "new_tab !neighbor sh -c \"${name-rnd}/bin/set-rnd-tab-title ; exec $SHELL\""; "${leader}>t>q" = "close_tab"; "${leader}>n" = "next_tab"; "${leader}>p" = "previous_tab"; "${leader}>shift+n" = "move_tab_forward"; "${leader}>shift+p" = "move_tab_backward"; "${leader}>comma" = "set_tab_title"; # Scrolling "${leader}>ctrl+b" = "scroll_page_up"; "${leader}>ctrl+f" = "scroll_page_down"; "${leader}>ctrl+g" = "scroll_home"; "${leader}>ctrl+shift+g" = "scroll_end"; "${leader}>ctrl+k" = "scroll_to_prompt -1"; "${leader}>ctrl+j" = "scroll_to_prompt 1"; "${leader}>ctrl+e" = "show_last_visited_command_output"; "${leader}>ctrl+shift+e" = "show_scrollback"; # Markers "${leader}>m>m" = "scroll_to_mark next"; "${leader}>m>shift+m" = "scroll_to_mark prev"; # Kittens "${leader}>d>u" = "open_url_with_hints"; "${leader}>d>f" = "kitten hints --type path --program -"; "${leader}>d>e" = "kitten unicode_input --tab name"; }; settings = { # Fonts disable_ligatures = "cursor"; undercurl_style = "thin-sparse"; # Scrollback scrollback_lines = 2048; scrollback_pager = "nvim -c \"silent write! $TMPDIR/kitty_scrollback_buffer | te cat $TMPDIR/kitty_scrollback_buffer - \""; scrollback_pager_history_size = 1; # in MB # Mouse strip_trailing_spaces = "smart"; # Terminal bell enable_audio_bell = false; bell_on_tab = "*"; # Window layouts enabled_layouts = "splits"; active_border_color = palette-yellow; inactive_border_color = palette-bg2; bell_border_color = palette-red; inactive_text_alpha = "0.5"; hide_window_decorations = false; # Tab bar tab_bar_edge = "top"; tab_bar_margin_width = "5.0"; tab_bar_margin_height = "4.0 0.0"; tab_bar_style = "custom"; tab_bar_align = "center"; tab_bar_min_tabs = 1; tab_title_template = "{title}{bell_symbol}"; active_tab_title_template = "{title}{bell_symbol}"; active_tab_font_style = "bold"; active_tab_foreground = palette-bg0; active_tab_background = palette-fg0; inactive_tab_foreground = palette-fg0; inactive_tab_background = palette-bg2; # Advanced # allow_remote_control = "password"; allow_remote_control = "yes"; update_check_interval = 0; }; extraConfig = '' modify_font underline_position 2 modify_font underline_thickness 50% modify_font strikethrough_position -1 # Allow the following commands without passphrase. #remote_control_password "" set-*-title *-marker ''; }; xdg.configFile."kitty/tab_bar.py" = { source = config/terminal/tab_bar.py; target = "kitty/tab_bar.py"; }; }