From 2c66524d18da4e68cf947d36455e3c26a12260d8 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 7 Jul 2025 12:00:00 +0100 Subject: [PATCH] Update tmux-sessionizer --- home/opdavies/PW05CH3L.nix | 6 +- home/opdavies/t480.nix | 2 +- modules/home-manager/cli/tmux-sessionizer.nix | 67 +++++++++---------- pkgs/tmux-sessionizer/default.nix | 21 ++---- .../move-default-script.patch | 15 ----- .../shorten-suggested-paths.patch | 22 ------ pkgs/tmux-sessionizer/sort-suggestions.patch | 13 ---- 7 files changed, 38 insertions(+), 108 deletions(-) delete mode 100644 pkgs/tmux-sessionizer/move-default-script.patch delete mode 100644 pkgs/tmux-sessionizer/shorten-suggested-paths.patch delete mode 100644 pkgs/tmux-sessionizer/sort-suggestions.patch diff --git a/home/opdavies/PW05CH3L.nix b/home/opdavies/PW05CH3L.nix index b8ce7248..6cc66307 100644 --- a/home/opdavies/PW05CH3L.nix +++ b/home/opdavies/PW05CH3L.nix @@ -23,16 +23,14 @@ tmux-sessionizer = { enable = true; - directories = + searchPaths = let inherit (config.xdg.userDirs) documents extraConfig; repos = extraConfig.XDG_REPOS_DIR; in - options.cli.tmux-sessionizer.directories.default - ++ [ + [ repos - "${repos}/*" documents ]; }; diff --git a/home/opdavies/t480.nix b/home/opdavies/t480.nix index e1793a92..db6f707c 100644 --- a/home/opdavies/t480.nix +++ b/home/opdavies/t480.nix @@ -35,7 +35,7 @@ enable = true; enableDmenuIntegration = true; - directories = + searchPaths = let inherit (config.xdg.userDirs) documents extraConfig; diff --git a/modules/home-manager/cli/tmux-sessionizer.nix b/modules/home-manager/cli/tmux-sessionizer.nix index 97ca9086..9b5a8765 100644 --- a/modules/home-manager/cli/tmux-sessionizer.nix +++ b/modules/home-manager/cli/tmux-sessionizer.nix @@ -15,56 +15,49 @@ in enable = mkEnableOption "Enable tmux-sessionizer"; enableDmenuIntegration = mkEnableOption "Enable dmenu integration"; - directories = mkOption { + searchPaths = mkOption { default = [ config.home.homeDirectory ]; type = types.listOf types.str; - description = "List of directories for tmux-sessionizer to use."; + description = "List of search paths for tmux-sessionizer to use."; }; + + # TODO: add TS_EXTRA_SEARCH_PATHS. + # TODO: add TS_MAX_DEPTH. + # TODO: add TS_SESSION_COMMANDS once I figure out what they're for. }; config = mkIf cfg.enable { home.packages = with pkgs; [ tmux-sessionizer - ] ++ (optional cfg.enableDmenuIntegration ( - pkgs.writeShellApplication { - name = "tmux-sessionizer-dmenu"; + ]; - text = '' - # shellcheck disable=SC2046 - selected=$(find $(eval echo "$(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")") -mindepth 1 -maxdepth 1 -type d | dmenu -i -l 20) + home.file.".tmux-sessionizer".source = "${ + pkgs.writeShellApplication { + name = ".tmux-sessionizer"; - ${pkgs.coreutils}/bin/nohup st -e tmux-sessionizer "$selected" >/dev/null 2>&1 & - ''; - } - )); + runtimeInputs = with pkgs; [ + tmux + ]; - xdg.configFile = { - "tmux-sessionizer/default".source = "${ - pkgs.writeShellApplication { - name = ".tmux-sessionizer"; + text = '' + set +o errexit + set +o nounset - runtimeInputs = with pkgs; [ - tmux - ]; - - text = '' - set +o errexit - set +o nounset - - if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/work" ]]; then - clear - - return - fi - - tmux new-window -d -n scratch - nvim . + if [[ "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/os" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/personal" || "$PWD" == "${config.xdg.userDirs.extraConfig.XDG_REPOS_DIR}/work" ]]; then clear - ''; - } - }/bin/.tmux-sessionizer"; - "tmux-sessionizer/directories".text = builtins.concatStringsSep "\n" cfg.directories; - }; + return + fi + + tmux new-window -d -n scratch + nvim . + clear + ''; + } + }/bin/.tmux-sessionizer"; + + xdg.configFile."tmux-sessionizer/tmux-sessionizer.conf".text = '' + TS_SEARCH_PATHS=(${builtins.concatStringsSep " " cfg.searchPaths}) + ''; }; } diff --git a/pkgs/tmux-sessionizer/default.nix b/pkgs/tmux-sessionizer/default.nix index aeb12dca..07077e99 100644 --- a/pkgs/tmux-sessionizer/default.nix +++ b/pkgs/tmux-sessionizer/default.nix @@ -4,13 +4,13 @@ with pkgs; stdenv.mkDerivation { pname = "tmux-sessionizer"; - version = "unstable-2024-10-30"; + version = "unstable-2025-06-19"; src = fetchFromGitHub { owner = "theprimeagen"; repo = "tmux-sessionizer"; - rev = "6ebd16e2e30a8c0ebd77f0c2ce18cb46db8397fa"; - sha256 = "bZXt9TyMU1Ed/WR0/ahMQ4oyIi6yXLKnXKYPPNBt/s4="; + rev = "7edf8211e36368c29ffc0d2c6d5d2d350b4d729b"; + sha256 = "sha256-4QGlq/cLbed7AZhQ3R1yH+44gmgp9gSzbiQft8X5NwU="; }; buildInputs = [ @@ -19,22 +19,11 @@ stdenv.mkDerivation { tmux ]; - patches = [ - ./move-default-script.patch - - (fetchpatch { - name = "feat: Made folders more dynamic"; - url = "https://patch-diff.githubusercontent.com/raw/ThePrimeagen/tmux-sessionizer/pull/2.patch"; - sha256 = "sha256-4/4rzve49T3FHnl9WWUPJVcb0NQojMQjIVnEZGwVAsY="; - }) - - ./shorten-suggested-paths.patch - ./sort-suggestions.patch - ]; - installPhase = '' mkdir -p $out/bin cp tmux-sessionizer $out/bin/tmux-sessionizer chmod +x $out/bin/tmux-sessionizer ''; + + # TODO: create another patch to sort results. } diff --git a/pkgs/tmux-sessionizer/move-default-script.patch b/pkgs/tmux-sessionizer/move-default-script.patch deleted file mode 100644 index 6922915e..00000000 --- a/pkgs/tmux-sessionizer/move-default-script.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/tmux-sessionizer b/tmux-sessionizer -index fa1bec5..536d4b0 100755 ---- a/tmux-sessionizer -+++ b/tmux-sessionizer -@@ -14,8 +14,8 @@ has_session() { - hydrate() { - if [ -f $2/.tmux-sessionizer ]; then - tmux send-keys -t $1 "source $2/.tmux-sessionizer" c-M -- elif [ -f $HOME/.tmux-sessionizer ]; then -- tmux send-keys -t $1 "source $HOME/.tmux-sessionizer" c-M -+ elif [ -f "$XDG_CONFIG_HOME/tmux-sessionizer/default" ]; then -+ tmux send-keys -t $1 "source $XDG_CONFIG_HOME/tmux-sessionizer/default" c-M - fi - } - diff --git a/pkgs/tmux-sessionizer/shorten-suggested-paths.patch b/pkgs/tmux-sessionizer/shorten-suggested-paths.patch deleted file mode 100644 index 067cbe64..00000000 --- a/pkgs/tmux-sessionizer/shorten-suggested-paths.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/tmux-sessionizer b/tmux-sessionizer -index 8fa4153..3e607d7 100755 ---- a/tmux-sessionizer -+++ b/tmux-sessionizer -@@ -22,13 +22,16 @@ hydrate() { - if [[ $# -eq 1 ]]; then - selected=$1 - else -- selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | fzf) -+ selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | sed "s|$HOME/||" | fzf) - fi - - if [[ -z $selected ]]; then - exit 0 - fi - -+# Add Home path back. -+selected="$HOME/$selected" -+ - selected_name=$(basename "$selected" | tr . _) - tmux_running=$(pgrep tmux) - diff --git a/pkgs/tmux-sessionizer/sort-suggestions.patch b/pkgs/tmux-sessionizer/sort-suggestions.patch deleted file mode 100644 index c2d33126..00000000 --- a/pkgs/tmux-sessionizer/sort-suggestions.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/tmux-sessionizer b/tmux-sessionizer -index 3e607d7..27729b1 100755 ---- a/tmux-sessionizer -+++ b/tmux-sessionizer -@@ -22,7 +22,7 @@ hydrate() { - if [[ $# -eq 1 ]]; then - selected=$1 - else -- selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | sed "s|$HOME/||" | fzf) -+ selected=$(find $(eval echo $(xargs < "$XDG_CONFIG_HOME/tmux-sessionizer/directories")) -mindepth 1 -maxdepth 1 -type d | sed "s|$HOME/||" | sort | fzf) - fi - - if [[ -z $selected ]]; then