1
0
فهرست منبع

making moving between windows and tmux splits work

Zander Hawke 1 سال پیش
والد
کامیت
6a6da8f217

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

@@ -11,6 +11,7 @@
     ./nushell.nix
     ./ssh.nix
     ./starship.nix
+    ./tmux.nix
     ./yazi.nix
     ./zoxide.nix
     ./zsh.nix

+ 9 - 50
home/features/cli/tmux.nix

@@ -1,7 +1,5 @@
-{ inputs, pkgs, ... }:
+{ pkgs, config, ... }:
 {
-  # home.packages = [ pkgs.tmux-cht ];
-
 # - WARNING Neither Tc nor RGB capability set. True colors are disabled. |'termguicolors'| won't work properly.
 #   - ADVICE:
 #     - Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
@@ -10,6 +8,8 @@
 #       set-option -ga terminal-overrides ',XXX:Tc'
 
   programs.tmux = {
+    sensibleOnTop = false;
+
     baseIndex = 1;
     clock24 = true;
     enable = true;
@@ -17,10 +17,13 @@
     keyMode = "vi";
     mouse = true;
     prefix = "C-a";
-    shell = "${pkgs.fish}/bin/fish";
+    # shell = "${pkgs.fish}/bin/fish";
+    shell = "${pkgs.lib.meta.getExe config.programs.fish.package}";
     terminal = "tmux-256color";
 
     plugins = with pkgs.tmuxPlugins; [
+      pkgs.more-tmux-plugins.tmux-select-pane-no-wrap
+      nord
       vim-tmux-navigator
       {
         plugin = yank;
@@ -45,56 +48,12 @@
       bind -r j resize-pane -D 1
       bind -r k resize-pane -U 1
 
-      # Obsidian keybindings
-      bind-key o switch-client -T obsidian
-      bind-key -T obsidian t display-popup -h 100% -w 100% -x 0% -E "nvim -c 'ObsidianToday' -c 'ZenMode'"
-      bind-key -T obsidian d display-popup -h 100% -w 100% -x 0% -E "nvim -c 'ObsidianDailies' -c 'ZenMode'"
-      bind-key -T obsidian y display-popup -h 100% -w 100% -x 0% -E "nvim -c 'ObsidianYesterday' -c 'ZenMode'"
-      bind-key -T obsidian n display-popup -h 100% -w 100% -x 0% -E "nvim -c 'ObsidianNew' -c 'ZenMode'"
+      # change width of left status bar to allow space for session names
+      set -g status-left-length 30
 
       # - Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
       set-option -sa terminal-features ',xterm-256color:RGB'
 
-      ## COLORSCHEME: kanagawa dark
-      # taken from gruvbox and changed toLmy needs: https://github.com/egel/tmux-gruvbox/blob/main/tmux-gruvbox-dark.conf
-      set-option -g status "on"
-      # default statusbar color
-      set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
-      # default window title colors
-      set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
-      # default window with an activity alert
-      set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
-      # active window title colors
-      set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
-      # pane border
-      set-option -g pane-active-border-style fg=colour250 #fg2
-      set-option -g pane-border-style fg=colour237 #bg1
-      # message infos
-      set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
-      # writing commands inactive
-      set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
-      # pane number display
-      set-option -g display-panes-active-colour colour250 #fg2
-      set-option -g display-panes-colour colour237 #bg1
-      # clock
-      set-window-option -g clock-mode-colour colour109 #blue
-      # bell
-      set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
-      # Theme settings mixed with colors (unfortunately, but there is no cleaner way)
-      set-option -g status-justify "left"
-      set-option -g status-left-style none
-      set-option -g status-left-length "80"
-      set-option -g status-right-style none
-      set-option -g status-right-length "80"
-      set-window-option -g window-status-separator ""
-
-      # status bar
-      set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
-      set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d  %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h "
-
-      set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W#{?window_zoomed_flag,*Z,} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]"
-      set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]"
-
       # default layout
       set-hook -g after-new-window 'split-window -h -p 30; split-window -v -p 66; split-window -v -p 50'
     '';

+ 0 - 20
home/features/desktop/ghostty.nix

@@ -71,26 +71,6 @@
       window-padding-x = 12;
       window-padding-y = 12;
       window-theme = "ghostty";
-
-      # clearDefaultKeybindings = true;
-      keybind = [
-        "ctrl+a>r=reload_config"
-
-        "ctrl+a>shift+5=new_split:right"
-        "ctrl+a>shift+'=new_split:down"
-
-        "ctrl+j=goto_split:bottom"
-        "ctrl+k=goto_split:top"
-        "ctrl+h=goto_split:left"
-        "ctrl+l=goto_split:right"
-
-        "ctrl+a>z=toggle_split_zoom"
-
-        "ctrl+shift+j=resize_split:down,10"
-        "ctrl+shift+k=resize_split:up,10"
-        "ctrl+shift+h=resize_split:left,10"
-        "ctrl+shift+l=resize_split:right,10"
-      ];
     };
   };
 }

+ 50 - 9
hosts/meili/aerospace.nix

@@ -1,4 +1,45 @@
+{ pkgs, config, ... }:
+
+let
+  cfg = config.services.aerospace;
+  aerospace = "${pkgs.lib.meta.getExe cfg.package}";
+  tmux = "${pkgs.lib.meta.getExe pkgs.tmux}";
+
+  script = pkgs.writeShellScriptBin "aerospace-focus" ''
+    direction="$1"
+
+    if [[ -n "$(${aerospace} list-windows --focused | grep tmux)" ]]; then
+      tmux_dir=""
+
+      case "$direction" in
+        left) tmux_dir="L" ;;
+        down) tmux_dir="D" ;;
+        up) tmux_dir="U" ;;
+        right) tmux_dir="R" ;;
+      esac
+
+      if [[ -n "$tmux_dir" ]]; then
+        ret=$(${tmux} run "#{at_edge} $tmux_dir")
+
+        if [[ $ret -eq 1 ]]; then
+          ${aerospace} focus "$direction"
+        else
+          ${tmux} select-pane "-$tmux_dir"
+        fi
+      fi
+    fi
+
+    ${aerospace} focus "$direction"
+  '';
+
+  aerospace-focus = "${pkgs.lib.meta.getExe script}";
+in
+
 {
+  # TODO: this needs to go to the home-manager config
+
+  environment.systemPackages = [ script ];
+
   services.aerospace = {
     enable = true;
     settings = {
@@ -19,9 +60,9 @@
         alt-5 = "workspace 5";
         alt-b = "workspace B"; # Browser
         alt-e = "workspace E"; # Finder
-        alt-t = "workspace T"; # Terminal
         alt-m = "workspace M"; # Mail
         alt-s = "workspace S"; # Signal
+        alt-t = "workspace T"; # Terminal
         alt-v = "workspace V"; # Video
 
         # moving windows to workspaces
@@ -40,16 +81,16 @@
         alt-shift-f = "fullscreen";
 
         # focus between windows
-        alt-h = "focus left";
-        alt-l = "focus right";
-        alt-k = "focus up";
-        alt-j = "focus down";
+        ctrl-h = "exec-and-forget ${aerospace-focus} left";
+        ctrl-l = "exec-and-forget ${aerospace-focus} right";
+        ctrl-k = "exec-and-forget ${aerospace-focus} up";
+        ctrl-j = "exec-and-forget ${aerospace-focus} down";
 
         # move between windows
-        alt-shift-h = "move left";
-        alt-shift-l = "move right";
-        alt-shift-k = "move up";
-        alt-shift-j = "move down";
+        ctrl-shift-h = "move left";
+        ctrl-shift-l = "move right";
+        ctrl-shift-k = "move up";
+        ctrl-shift-j = "move down";
 
         alt-shift-minus = "resize smart -50";
         alt-shift-equal = "resize smart +50";

+ 1 - 0
packages/default.nix

@@ -6,4 +6,5 @@
   hello = pkgs.callPackage ./hello.nix { };
   photo-cli = pkgs.callPackage ./photo-cli.nix { };
   zen-browser = pkgs.callPackage ./zen-browser { };
+  more-tmux-plugins = pkgs.callPackage ./more-tmux-plugins.nix { };
 }

+ 1 - 1
packages/more-tmux-plugins.nix

@@ -58,7 +58,7 @@ in rec {
       owner = "dalejung";
       repo = pluginName;
       rev = version;
-      sha256 = "";
+      sha256 = "sha256-ot0cHvk1TXvHOw9z+7TLSiHT77jHwvV2PSHcNuhOorQ=";
     };
   };
 }

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

@@ -1,11 +0,0 @@
-{ mkTmuxPlugin, fetchFromGitHub }:
-mkTmuxPlugin rec {
-  pluginName = "tmux-select-pane-no-wrap";
-  version = "00add78";
-  src = fetchFromGitHub {
-    owner = "dalejung";
-    repo = pluginName;
-    rev = version;
-    sha256 = "";
-  };
-}