From 88e093176251412542977571e62a29929d924891 Mon Sep 17 00:00:00 2001 From: Dennis Schoepf Date: Sat, 10 Jan 2026 20:21:13 +0100 Subject: [PATCH] improves tmux config --- modules/fish/default.nix | 16 +++++++++++----- modules/tmux/default.nix | 23 ++++++++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/modules/fish/default.nix b/modules/fish/default.nix index 523179d..fac5a87 100644 --- a/modules/fish/default.nix +++ b/modules/fish/default.nix @@ -70,18 +70,24 @@ end ''; sessionizer = /* fish */ '' - set -l selected (dev_projects | fzf --prompt "Create/switch to session: ") + set -l selected (dev_projects | fzf --prompt "Create/switch to session: " --reverse --header ' Ctrl-d: Kill Session' --bind 'ctrl-d:execute(tmux kill-session -t {2..})++reload(dev_projects)') if test -z "$selected" return 1 end set -l session_name (basename $selected) + set -l tmux_runnning (pgrep tmux) - if test $ZELLIJ -eq 0 - zellij pipe --plugin file:/run/current-system/sw/bin/zellij-switch.wasm -- "--session $session_name --cwd $selected --layout default" - else - zellij attach "$session_name" --create + if test -z $TMUX and -z @tmux_running + tmux new-session -s $selected_name -c $selected + return 0 end + + if not tmux has-session -t=$selected_name 2> /dev/null + tmux new-session -ds $selected_name -c $selected + end + + tmux switch-client -t $selected_name ''; nn = /* fish */ '' # Require a title argument diff --git a/modules/tmux/default.nix b/modules/tmux/default.nix index fba9878..bc944de 100644 --- a/modules/tmux/default.nix +++ b/modules/tmux/default.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: { programs.tmux = { @@ -31,23 +36,31 @@ ]; extraConfig = '' unbind % - bind | split-window -h + bind "|" split-window -h unbind '"' - bind - split-window -v + bind - split-window -l 30 -v - bind r source-file ~/.tmux.conf \; display "Config reloaded!" + bind r source-file ~/.config/tmux/tmux.conf \; display "Config reloaded!" bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R - + bind -r H resize-pane -L 5 bind -r J resize-pane -D 5 bind -r K resize-pane -U 5 bind -r L resize-pane -R 5 bind ? list-keys -a + + unbind s + bind s display-popup -h 50% -w 50% -E sessionizer + + unbind "+" + bind "+" choose-tree -Zw "join-pane -t '%%'" + + set -g mode-keys vi ''; }; }