Update tmux-sessionizer
All checks were successful
/ check (push) Successful in 1m47s

This commit is contained in:
Oliver Davies 2025-07-07 12:00:00 +01:00
parent 533b8db65f
commit 2c66524d18
7 changed files with 38 additions and 108 deletions

View file

@ -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})
'';
};
}