Commit e373e55fca21

Vincent Demeester <vincent@sbr.pm>
2026-01-16 22:55:05
feat(kitty,ssh): enable CWD tracking in remote shpool sessions
- Allow new kitty windows to inherit CWD from remote SSH sessions - Improve security by restricting remote control to socket-only - Add session management keybindings for workflow efficiency Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent ac9878a
Changed files (3)
home
home/common/desktop/kitty.nix
@@ -7,8 +7,8 @@
       close_on_child_death = "yes";
       font_family = "JetBrains Mono";
       tab_bar_edge = "top";
+      allow_remote_control = "socket-only";
       listen_on = "unix:/tmp/my-kitty";
-      allow_remote_control = "yes";
       macos_option_as_alt = "yes";
       copy_on_select = "yes";
       notify_on_cmd_finish = "invisible 5.0 notify";
@@ -27,6 +27,10 @@
       "shift+right" = "neighboring_window right";
       "shift+up" = "neighboring_window up";
       "shift+down" = "neighboring_window down";
+      "ctrl+shift+enter" = "new_window_with_cwd";
+
+      "ctrl+shift+s" = "goto_session ~/.config/kitty/sessions";
+      "ctrl+alt+shift+s" = "save_as_session --use-foreground-process --relocatable";
     };
 
     # Bépo-optimized tmux conditional bindings (Alt-based, context-aware)
home/common/shell/openssh.nix
@@ -50,7 +50,8 @@
                   else
                     id;
                 extraOptions = {
-                  RemoteCommand = "shpool-ssh-wrapper $(echo '%k' | cut -d/ -f2-)";
+                  # RemoteCommand = "shpool-ssh-wrapper $(echo '%k' | cut -d/ -f2-)";
+                  RemoteCommand = "bash -ic '[ -f ~/.local/share/kitty-ssh-kitten/zsh/kitty-integration ] && source ~/.local/share/kitty-ssh-kitten/zsh/kitty-integration 2>/dev/null; exec shpool-ssh-wrapper $(echo \"%k\" | cut -d/ -f2-)'";
                   RequestTTY = "yes";
                 };
               };
home/common/shell/zsh.nix
@@ -1,4 +1,4 @@
-{ config, pkgs, ... }:
+{ config, lib, pkgs, desktop ? null, ... }:
 {
   home.file."${config.programs.zsh.dotDir}/completion.zsh".source = ./zsh/completion.zsh;
   home.file."${config.programs.zsh.dotDir}/prompt.zsh".source = ./zsh/prompt.zsh;
@@ -6,6 +6,15 @@
   home.file."${config.programs.zsh.dotDir}/auto-expanding-aliases.zsh".source =
     ./zsh/auto-expanding-aliases.zsh;
 
+  # Kitty shell integration for CWD tracking in shpool sessions
+  # Only deploy on headless servers (not on desktops/laptops)
+  home.file.".local/share/kitty-ssh-kitten/shell-integration/zsh/kitty-integration" = lib.mkIf (desktop == null) {
+    source = "${pkgs.kitty}/lib/kitty/shell-integration/zsh/kitty-integration";
+  };
+  home.file.".local/share/kitty-ssh-kitten/shell-integration/zsh/kitty.zsh" = lib.mkIf (desktop == null) {
+    source = "${pkgs.kitty}/lib/kitty/shell-integration/zsh/kitty.zsh";
+  };
+
   home.packages = with pkgs; [
     nix-zsh-completions
   ];
@@ -107,6 +116,13 @@
       			# 	exec dbus-run-session niri-session
             # fi
     '';
+    initExtra = ''
+      # Kitty shell integration (enables CWD tracking in shpool sessions)
+      # This allows new_window_with_cwd to work when using ssh host/session pattern
+      if [[ -f ~/.local/share/kitty-ssh-kitten/shell-integration/zsh/kitty-integration ]]; then
+        source ~/.local/share/kitty-ssh-kitten/shell-integration/zsh/kitty-integration
+      fi
+    '';
     sessionVariables = {
       RPROMPT = "";
     };