From e05f1a7805da3c9821ab73276e873e55148061be Mon Sep 17 00:00:00 2001 From: Natalie Marks Date: Wed, 29 Oct 2025 18:02:50 -0700 Subject: [PATCH] feat: add tmux config --- users/natalie/home.nix | 3 + users/natalie/home/default.nix | 6 ++ users/natalie/home/tmux.nix | 107 +++++++++++++++++++++++++++++++++ users/natalie/packages.nix | 1 - 4 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 users/natalie/home/default.nix create mode 100644 users/natalie/home/tmux.nix diff --git a/users/natalie/home.nix b/users/natalie/home.nix index 448e7018660df48df450d25ef9ad9bafbdb090af..43f27d39f84f27952928fb959dcb481cb7465c82 100644 --- a/users/natalie/home.nix +++ b/users/natalie/home.nix @@ -5,6 +5,9 @@ ... }@args: { + imports = [ + ./home + ]; programs = { # sort-lines:start atuin.enable = true; diff --git a/users/natalie/home/default.nix b/users/natalie/home/default.nix new file mode 100644 index 0000000000000000000000000000000000000000..e1d7054f5eb20ca2e8541e06050e270dca53c57b --- /dev/null +++ b/users/natalie/home/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./tmux.nix + ]; +} diff --git a/users/natalie/home/tmux.nix b/users/natalie/home/tmux.nix new file mode 100644 index 0000000000000000000000000000000000000000..edf6f008bb2cc6167ce783164f29edbd57fe11b6 --- /dev/null +++ b/users/natalie/home/tmux.nix @@ -0,0 +1,107 @@ +{ pkgs, config, ... }: +let + tmux-nvim = pkgs.tmuxPlugins.mkTmuxPlugin { + pluginName = "tmux.nvim"; + version = "unstable-2025-05-19"; + src = pkgs.fetchFromGitHub { + owner = "aserowy"; + repo = "tmux.nvim/"; + rev = "2c1c3be0ef287073cef963f2aefa31a15c8b9cd8"; + sha256 = "sha256-/XIjqQr9loWVTXZDaZx2bSQgco46z7yam50dCnM5p1U="; + }; + }; + +in +{ + programs.tmux = { + enable = true; + mouse = true; + + shell = "${pkgs.fish}/bin/fish"; + + shortcut = "a"; + keyMode = "vi"; + + plugins = with pkgs.tmuxPlugins; [ + better-mouse-mode + tmux-nvim + tmux-thumbs + cpu + tmux-floax + yank + # must be before continuum edits right status bar + { + plugin = catppuccin; + extraConfig = '' + set -g @catppuccin_flavour "mocha" + set -g @catppuccin_window_status_style "rounded" + + set -g status-right-length 100 + set -g status-left-length 100 + set -g status-left "" + set -g status-right "#{E:@catppuccin_status_application}" + set -ag status-right "#{E:@catppuccin_status_session}" + set -ag status-right "#{E:@catppuccin_status_uptime}" + + ''; + } + { + plugin = resurrect; + extraConfig = '' + set -g @resurrect-strategy-vim 'session' + set -g @resurrect-strategy-nvim 'session' + set -g @resurrect-capture-pane-contents 'on' + '' + + '' + # Taken from: https://github.com/p3t33/nixos_flake/blob/5a989e5af403b4efe296be6f39ffe6d5d440d6d6/home/modules/tmux.nix + resurrect_dir="$XDG_CACHE_HOME/.tmux/resurrect" + set -g @resurrect-dir $resurrect_dir + + set -g @resurrect-hook-post-save-all 'target=$(readlink -f $resurrect_dir/last); sed "s| --cmd .*-vim-pack-dir||g; s|/etc/profiles/per-user/$USER/bin/||g; s|/home/$USER/.nix-profile/bin/||g" $target | sponge $target' + ''; + + } + { + plugin = continuum; + extraConfig = '' + set -g @continuum-restore 'on' + set -g @continuum-boot 'on' + set -g @continuum-save-interval '10' + set -g @continuum-systemd-start-cmd 'start-server' + ''; + } + + ]; + extraConfig = '' + set -g default-terminal "tmux-256color" + set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.local/share/tmux/plugins' + # Easier reload of config + bind r source-file ~/.config/tmux/tmux.conf + # Quicker escape in neovim + set -sg escape-time 0 + set-option -g set-titles on + set-option -g set-titles-string "#S / #W" + + set -g allow-passthrough on + + # '@pane-is-vim' is a pane-local option that is set by the plugin on load, + # and unset when Neovim exits or suspends; note that this means you'll probably + # not want to lazy-load smart-splits.nvim, as the variable won't be set until + # the plugin is loaded + + # Smart pane switching with awareness of Neovim splits. + bind-key -n C-h if -F "#{@pane-is-vim}" 'send-keys C-h' 'select-pane -L' + bind-key -n C-j if -F "#{@pane-is-vim}" 'send-keys C-j' 'select-pane -D' + bind-key -n C-k if -F "#{@pane-is-vim}" 'send-keys C-k' 'select-pane -U' + bind-key -n C-l if -F "#{@pane-is-vim}" 'send-keys C-l' 'select-pane -R' + + # Smart pane resizing with awareness of Neovim splits. + bind-key -n M-h if -F "#{@pane-is-vim}" 'send-keys M-h' 'resize-pane -L 3' + bind-key -n M-j if -F "#{@pane-is-vim}" 'send-keys M-j' 'resize-pane -D 3' + bind-key -n M-k if -F "#{@pane-is-vim}" 'send-keys M-k' 'resize-pane -U 3' + bind-key -n M-l if -F "#{@pane-is-vim}" 'send-keys M-l' 'resize-pane -R 3' + + ''; + }; + +} diff --git a/users/natalie/packages.nix b/users/natalie/packages.nix index cbfbf8a7eaff528e761f7742129f0325d54cc61f..5a280c31a78733af85c510ac97cb52f4a925b804 100644 --- a/users/natalie/packages.nix +++ b/users/natalie/packages.nix @@ -43,7 +43,6 @@ with pkgs; #terminal stuff (btop.override { cudaSupport = true; }) - tmux zellij lazygit fzf -- 2.54.0