Bläddra i källkod

feat(tmux): migrate from zellij to tmux

This commit replaces the existing zellij configuration with a new, more detailed tmux setup.

The new tmux configuration includes:
- A customized theme (Kanagawa).
- Plugins for pane navigation, yanking, and more.
- Keybindings for pop-up windows with lazygit and a new shell.

Additionally, the neovim and aerospace configurations have been updated to integrate seamlessly with tmux, allowing for consistent navigation across applications and terminal panes.
Zander Hawke 8 månader sedan
förälder
incheckning
fa548b34d1

+ 1 - 1
home/features/cli/default.nix

@@ -7,7 +7,7 @@
     ./gnupg.nix
     ./ssh.nix
     ./starship.nix
-    ./zellij.nix
+    ./tmux.nix
   ];
 
   home.packages = [

+ 86 - 0
home/features/cli/tmux.nix

@@ -0,0 +1,86 @@
+{ pkgs
+, config
+, lib
+, ...
+}:
+let
+  isDarwin = pkgs.stdenv.isDarwin;
+  reattach-to-user-namespace = lib.getExe' pkgs.reattach-to-user-namespace "reattach-to-user-namespace";
+  lazygit = lib.getExe pkgs.lazygit;
+  shell = lib.getExe config.programs.fish.package;
+in
+{
+  home.packages = with pkgs; [ eza ];
+
+  programs.tmux = {
+    sensibleOnTop = true;
+
+    baseIndex = 1;
+    clock24 = true;
+    enable = true;
+    escapeTime = 10;
+    keyMode = "vi";
+    mouse = true;
+    prefix = "C-b";
+    shell = "${lib.getExe config.programs.fish.package}";
+    terminal = "tmux-256color";
+
+    plugins = with pkgs.tmuxPlugins; [
+      tmux-select-pane-no-wrap
+      vim-tmux-navigator
+      yank
+      {
+        plugin = kanagawa;
+        extraConfig = ''
+          set -g status-position top
+          set -g @kanagawa-theme 'dragon'
+          set -g @kanagawa-refresh-rate 60
+          set -g @kanagawa-show-left-icon window
+          set -g @kanagawa-show-battery true
+          set -g @kanagawa-show-powerline true
+          # set -g @kanagawa-show-left-sep 
+          # set -g @kanagawa-show-right-sep 
+          # set -g @kanagawa-show-left-sep 
+          # set -g @kanagawa-show-right-sep 
+          # set -g @kanagawa-show-left-sep 
+          # set -g @kanagawa-show-right-sep 
+          # set -g @kanagawa-show-left-sep 
+          # set -g @kanagawa-show-right-sep 
+          set -g @kanagawa-show-left-sep 
+          set -g @kanagawa-show-right-sep 
+          set -g @kanagawa-show-location false
+          set -g @kanagawa-ignore-window-colors true
+        '';
+      }
+    ];
+
+    extraConfig = ''
+      ${lib.optionalString isDarwin ''
+        # sensible plugin assumes $SHELL is /bin/sh
+        # --- Darwin-Specific Settings (Raw Tmux Commands) ---
+        # This block is only included if the system is Darwin
+        set-option -g default-command "${reattach-to-user-namespace} -l $SHELL"
+      ''}
+
+      # split windows on the current path
+      unbind %
+      unbind '"'
+      bind-key %      split-window -h -c '#{pane_current_path}'
+      bind-key '"'    split-window -v -c '#{pane_current_path}'
+
+      # resize pane with vim motion keys
+      bind-key -r h resize-pane -L 1
+      bind-key -r l resize-pane -R 1
+      bind-key -r j resize-pane -D 1
+      bind-key -r k resize-pane -U 1
+
+      # move between tmux windows
+      bind-key -n C-e select-window -t :1
+      bind-key -n C-a select-window -t :2
+
+      # some display popups
+      bind-key -n C-g display-popup -d "#{pane_current_path}" -w 80% -h 80% -E "${lazygit}"
+      bind-key -n C-t display-popup -d "#{pane_current_path}" -w 75% -h 75% -E "${shell}"
+    '';
+  };
+}

+ 26 - 43
home/features/desktop/aerospace.nix

@@ -1,4 +1,13 @@
+{ pkgs
+, lib
+, ...
+}:
+let
+  aerospace-focus = "${lib.getExe pkgs.aerospace-tmux-focus}";
+in
 {
+  home.packages = [ pkgs.aerospace-tmux-focus ];
+
   programs.aerospace = {
     enable = true;
     userSettings = {
@@ -6,14 +15,10 @@
 
       mode.main.binding = {
         # vim-style window focusing
-        # ctrl-h = "exec-and-forget ${aerospace-focus} left";
-        # ctrl-j = "exec-and-forget ${aerospace-focus} down";
-        # ctrl-k = "exec-and-forget ${aerospace-focus} up";
-        # ctrl-l = "exec-and-forget ${aerospace-focus} right";
-        ctrl-h = "focus left";
-        ctrl-j = "focus down";
-        ctrl-k = "focus up";
-        ctrl-l = "focus right";
+        ctrl-h = "exec-and-forget ${aerospace-focus} left";
+        ctrl-j = "exec-and-forget ${aerospace-focus} down";
+        ctrl-k = "exec-and-forget ${aerospace-focus} up";
+        ctrl-l = "exec-and-forget ${aerospace-focus} right";
 
         # vim-style window moving
         ctrl-shift-h = "move left";
@@ -42,38 +47,14 @@
         ctrl-shift-8 = "move-node-to-workspace 8";
 
         # follow window to workspace
-        ctrl-cmd-1 = [
-          "move-node-to-workspace 1"
-          "workspace 1"
-        ];
-        ctrl-cmd-2 = [
-          "move-node-to-workspace 2"
-          "workspace 2"
-        ];
-        ctrl-cmd-3 = [
-          "move-node-to-workspace 3"
-          "workspace 3"
-        ];
-        ctrl-cmd-4 = [
-          "move-node-to-workspace 4"
-          "workspace 4"
-        ];
-        ctrl-cmd-5 = [
-          "move-node-to-workspace 5"
-          "workspace 5"
-        ];
-        ctrl-cmd-6 = [
-          "move-node-to-workspace 6"
-          "workspace 6"
-        ];
-        ctrl-cmd-7 = [
-          "move-node-to-workspace 7"
-          "workspace 7"
-        ];
-        ctrl-cmd-8 = [
-          "move-node-to-workspace 8"
-          "workspace 8"
-        ];
+        ctrl-cmd-1 = [ "move-node-to-workspace 1" "workspace 1" ];
+        ctrl-cmd-2 = [ "move-node-to-workspace 2" "workspace 2" ];
+        ctrl-cmd-3 = [ "move-node-to-workspace 3" "workspace 3" ];
+        ctrl-cmd-4 = [ "move-node-to-workspace 4" "workspace 4" ];
+        ctrl-cmd-5 = [ "move-node-to-workspace 5" "workspace 5" ];
+        ctrl-cmd-6 = [ "move-node-to-workspace 6" "workspace 6" ];
+        ctrl-cmd-7 = [ "move-node-to-workspace 7" "workspace 7" ];
+        ctrl-cmd-8 = [ "move-node-to-workspace 8" "workspace 8" ];
 
         # window management
         ctrl-q = "close";
@@ -93,8 +74,11 @@
         # application launchers; not necessary since we're using app launcher
         alt-enter = "exec-and-forget open -a Ghostty";
         alt-e = "exec-and-forget open -a Finder";
-        alt-b = "exec-and-forget open -a Vivaldi.app -n --args --profile-directory=Default";
-        alt-v = "exec-and-forget open -a Vivaldi.app -n --args --profile-directory=YouTube";
+        alt-b = "exec-and-forget open -a Vivaldi.app";
+        alt-v = "exec-and-forget open -a \"Vivaldi.app\" -n --args --profile-directory=YouTube";
+        # ctrl-return      = "exec-and-forget open -a Terminal";
+        # ctrl-e           = "exec-and-forget open -a Finder";
+        # ctrl-b           = "exec-and-forget open -a Safari";
         # ctrl-d = "exec-and-forget open -a Raycast";
 
         # reload configuration; probably not necessary since we're using hm
@@ -122,7 +106,6 @@
         ctrl-r = "mode main";
       };
 
-      # FIXME: these don't work, probably because of toml
       on-window-detected = [
         # disable on "Picture-in-Picture"
         {

+ 33 - 39
home/features/nvim/default.nix

@@ -1,7 +1,6 @@
-{
-  inputs,
-  pkgs,
-  ...
+{ inputs
+, pkgs
+, ...
 }:
 {
   imports = [
@@ -19,7 +18,7 @@
   home.packages = [ pkgs.zig ];
 
   programs.nixvim.plugins = {
-    zellij-nav.enable = true;
+    tmux-navigator.enable = true;
     todo-comments.enable = true; # todo comments eg TODO, FIXME, etc
   };
 
@@ -86,12 +85,6 @@
           end
         '';
       }
-      {
-        event = "VimLeave";
-        desc = "Return to Zellij normal mode when leaving nvim.";
-        pattern = "*";
-        command = "silent !zellij action switch-mode normal";
-      }
     ];
 
     autoGroups = {
@@ -109,10 +102,34 @@
       # Exit terminal mode in the builtin terminal
       # { key = "<Esc><Esc>"; action = "<C-\\><C-n>"; mode = "t"; option.desc = "Exit terminal mode"; }
       # Keybinds to make split navigation easier. TODO: figure out if these work
-      # { key = "<C-h>"; action = "<C-w>h"; mode = "n"; options.desc = "Move focus to the left window"; }
-      # { key = "<C-l>"; action = "<C-w>l"; mode = "n"; options.desc = "Move focus to the right window"; }
-      # { key = "<C-j>"; action = "<C-w>j"; mode = "n"; options.desc = "Move focus to the lower window"; }
-      # { key = "<C-k>"; action = "<C-w>k"; mode = "n"; options.desc = "Move focus to the upper window"; }
+      {
+        key = "<C-h>";
+        action = "<C-w>h";
+        mode = "n";
+        options.desc = "Move focus to the left window";
+      }
+
+      {
+        key = "<C-l>";
+        action = "<C-w>l";
+        mode = "n";
+        options.desc = "Move focus to the right window";
+      }
+
+      {
+        key = "<C-j>";
+        action = "<C-w>j";
+        mode = "n";
+        options.desc = "Move focus to the lower window";
+      }
+
+      {
+        key = "<C-k>";
+        action = "<C-w>k";
+        mode = "n";
+        options.desc = "Move focus to the upper window";
+      }
+
       # Move highlighed blocks of code up and down
       {
         key = "K";
@@ -140,6 +157,7 @@
         mode = "n";
         options.desc = "Scroll down and center cursor";
       }
+
       {
         key = "<C-u>";
         action = "<C-u>zz";
@@ -160,30 +178,6 @@
         options.desc = "Find previous and center cursor";
       }
 
-      {
-        key = "<c-h>";
-        action = "<cmd>ZellijNavigateLeftTab<cr>";
-        options.silent = true;
-        options.desc = "navigate left or tab";
-      }
-      {
-        key = "<c-j>";
-        action = "<cmd>ZellijNavigateDown<cr>";
-        options.silent = true;
-        options.desc = "navigate down";
-      }
-      {
-        key = "<c-k>";
-        action = "<cmd>ZellijNavigateUp<cr>";
-        options.silent = true;
-        options.desc = "navigate up";
-      }
-      {
-        key = "<c-l>";
-        action = "<cmd>ZellijNavigateRightTab<cr>";
-        options.silent = true;
-        options.desc = "navigate right or tab";
-      }
     ];
   };
 }

+ 1 - 0
packages/default.nix

@@ -19,5 +19,6 @@
   nct6775-pwm-udev-package = pkgs.callPackage ./nct6775-pwm-udev-package.nix { };
   opencode-nvim = pkgs.callPackage ./opencode-nvim.nix { };
   photo-cli = pkgs.callPackage ./photo-cli.nix { };
+  tmux-select-pane-no-wrap = pkgs.callPackage ./tmux-select-pane-no-wrap.nix { };
   zapstore-cli = pkgs.callPackage ./zapstore-cli { };
 }

+ 15 - 0
packages/tmux-select-pane-no-wrap.nix

@@ -0,0 +1,15 @@
+{ fetchFromGitHub
+, tmuxPlugins
+,
+}:
+tmuxPlugins.mkTmuxPlugin rec {
+  pluginName = "select-pane-no-wrap";
+  version = "00add78";
+  rtpFilePath = "${pluginName}.tmux";
+  src = fetchFromGitHub {
+    owner = "dalejung";
+    repo = "tmux-${pluginName}";
+    rev = version;
+    sha256 = "sha256-ot0cHvk1TXvHOw9z+7TLSiHT77jHwvV2PSHcNuhOorQ=";
+  };
+}