From 4b53af1bf19d8252f4bdbd72443e65b5b8ad7f39 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 8 Apr 2025 09:52:34 +0200 Subject: [PATCH] Add some aliases to kitty --- home/fish/fish.nix | 8 +- .../programs/my-kakoune/fish-session.nix | 2 - home/modules/programs/my-kitty/default.nix | 147 +++++++++++------- nki-framework/configuration.nix | 3 + 4 files changed, 94 insertions(+), 66 deletions(-) diff --git a/home/fish/fish.nix b/home/fish/fish.nix index 88b19de..9cb4b9b 100644 --- a/home/fish/fish.nix +++ b/home/fish/fish.nix @@ -173,6 +173,7 @@ in cat = "bat --theme=GitHub "; catp = "bat --theme=GitHub -p "; l = "exa -l --color=always "; + e = "$EDITOR"; "cp+" = "rsync -avzP"; }; @@ -207,13 +208,6 @@ in echo (__original_fish_title) - fish end - # Set up an editor alias - if test -n "$EDITOR" - alias e="$EDITOR" - else - alias e="kak" - end - # Source iTerm2 integration if test -e ~/.iterm2_shell_integration.fish; and test $__CFBundleIdentifier = "com.googlecode.iterm2" source ~/.iterm2_shell_integration.fish diff --git a/home/modules/programs/my-kakoune/fish-session.nix b/home/modules/programs/my-kakoune/fish-session.nix index 777261b..5ecc13f 100644 --- a/home/modules/programs/my-kakoune/fish-session.nix +++ b/home/modules/programs/my-kakoune/fish-session.nix @@ -32,7 +32,6 @@ in # Rebind $VISUAL, $EDITOR and e command set -gx VISUAL "kak -c $kak_session" set -gx EDITOR "kak -c $kak_session" - alias e="kak -c $kak_session" ''; kill-kak-session = '' @@ -47,7 +46,6 @@ in # Rebind $VISUAL, $EDITOR and e command set -gx VISUAL "kak" set -gx EDITOR "kak" - alias e="kak" ''; }; programs.fish.tide = { diff --git a/home/modules/programs/my-kitty/default.nix b/home/modules/programs/my-kitty/default.nix index 42812c2..23a1270 100644 --- a/home/modules/programs/my-kitty/default.nix +++ b/home/modules/programs/my-kitty/default.nix @@ -76,73 +76,106 @@ with lib; }; }; - config.linux.graphical = mkIf (cfg.enable && cfg.setDefault) { - defaults.terminal.package = cfg.package; - }; + config = mkIf cfg.enable { + linux.graphical = mkIf cfg.setDefault { + defaults.terminal.package = cfg.package; + }; + programs.kitty = { + enable = true; - config.programs.kitty = mkIf cfg.enable { - enable = true; + package = cfg.package; - package = cfg.package; + font.package = pkgs.fantasque-sans-mono; + font.name = "Fantasque Sans Mono"; + font.size = cfg.fontSize; - font.package = pkgs.fantasque-sans-mono; - font.name = "Fantasque Sans Mono"; - font.size = cfg.fontSize; + settings = + let + # Background color and transparency + background = + if isNull cfg.background then + { + background_opacity = "0.93"; + dynamic_background_opacity = true; + } + else + { + background_image = "${cfg.background}"; + background_image_layout = "scaled"; + background_tint = "0.85"; + }; + in + mkMerge [ + background + { + # Scrollback (128MBs) + scrollback_pager_history_size = 128; - settings = - let - # Background color and transparency - background = - if isNull cfg.background then - { - background_opacity = "0.93"; - dynamic_background_opacity = true; - } - else - { - background_image = "${cfg.background}"; - background_image_layout = "scaled"; - background_tint = "0.85"; - }; - in - mkMerge [ - background - { - # Scrollback (128MBs) - scrollback_pager_history_size = 128; + # Disable Shell integration (leave it for Nix) + shell_integration = "no-rc"; - # Disable Shell integration (leave it for Nix) - shell_integration = "no-rc"; + # Allow remote control (for kakoune integration) + allow_remote_control = true; - # Allow remote control (for kakoune integration) - allow_remote_control = true; + # Mouse focus + focus_follows_mouse = true; + } + ]; - # Mouse focus - focus_follows_mouse = true; - } - ]; + keybindings = { + "${cfg.cmd}+shift+equal" = "no_op"; # Not possible with a JIS keyboard + "${cfg.cmd}+shift+^" = "change_font_size all +2.0"; # ... so use ^ instead - keybindings = { - "${cfg.cmd}+shift+equal" = "no_op"; # Not possible with a JIS keyboard - "${cfg.cmd}+shift+^" = "change_font_size all +2.0"; # ... so use ^ instead + ## Clear screen + "${cfg.cmd}+backspace" = "clear_terminal to_cursor active"; + "${cfg.cmd}+shift+backspace" = "clear_terminal reset active"; - ## Clear screen - "${cfg.cmd}+backspace" = "clear_terminal to_cursor active"; - "${cfg.cmd}+shift+backspace" = "clear_terminal reset active"; - ## Hints - "${cfg.cmd}+shift+p>n" = "kitten hints --type=linenum --linenum-action=tab kak {path} +{line}"; + ## Command scrolling + "${cfg.cmd}+shift+j" = "scroll_to_prompt 1"; + "${cfg.cmd}+shift+k" = "scroll_to_prompt -1"; + }; + + extraConfig = + let + # Nerd Fonts glyph map + glyphMap = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/Sharparam/dotfiles/main/kitty/.config/kitty/font-nerd-symbols.conf"; + hash = "sha256-1OaDWLC3y8ASD2ttRWWgPEpRnfKXu6H6vS3cFVpzT0o="; + }; + in + '' + include ${glyphMap} + ''; }; - extraConfig = - let - # Nerd Fonts glyph map - glyphMap = pkgs.fetchurl { - url = "https://raw.githubusercontent.com/Sharparam/dotfiles/main/kitty/.config/kitty/font-nerd-symbols.conf"; - hash = "sha256-1OaDWLC3y8ASD2ttRWWgPEpRnfKXu6H6vS3cFVpzT0o="; - }; - in - '' - include ${glyphMap} - ''; + # Open protocol + xdg.configFile."kitty/open-actions.conf".text = '' + protocol file + fragment_matches [0-9]+ + action launch --type=overlay --cwd=current -- $\{EDITOR} +$\{FRAGMENT} -- $\{FILE_PATH} + + # Open HTML files with xdg-open + protocol file + mime text/html + action launch xdg-open $\{FILE_PATH} + + # Open text files without fragments in the editor + protocol file + mime text/* + action launch --type=overlay --cwd=current -- $\{EDITOR} -- $\{FILE_PATH} + + # Open other files with xdg-open + protocol file + action launch xdg-open $\{FILE_PATH} + ''; + + programs.fish.shellAliases = { + e = lib.mkForce "kitten edit-in-kitty"; + "ssh+" = "kitten ssh"; + "clip" = "kitten clipboard"; + "rg" = "kitten hyperlinked-grep"; + "icat" = "kitten icat"; + "notify" = "kitten notify"; + }; }; } diff --git a/nki-framework/configuration.nix b/nki-framework/configuration.nix index f1aee13..3a5806e 100644 --- a/nki-framework/configuration.nix +++ b/nki-framework/configuration.nix @@ -115,6 +115,9 @@ services.dbus.packages = with pkgs; [ gcr ]; + services.avahi.enable = true; + networking.firewall.allowedTCPPorts = [ 8010 ]; + # Open ports in the firewall. # networking.firewall.allowedTCPPorts = [ ... ]; # networking.firewall.allowedUDPPorts = [ ... ];