nix-config/modules/home-manager/cli/tmux-sessionizer.nix

64 lines
1.5 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}:
with lib;
let
2025-05-03 16:50:27 +01:00
cfg = config.cli.tmux-sessionizer;
in
{
2025-05-03 16:50:27 +01:00
options.cli.tmux-sessionizer = {
enable = mkEnableOption "Enable tmux-sessionizer";
enableDmenuIntegration = mkEnableOption "Enable dmenu integration";
2025-07-07 12:00:00 +01:00
searchPaths = mkOption {
default = [ config.home.homeDirectory ];
type = types.listOf types.str;
2025-07-07 12:00:00 +01:00
description = "List of search paths for tmux-sessionizer to use.";
};
2025-07-07 12:00:00 +01:00
# 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
2025-07-07 12:00:00 +01:00
];
2025-07-07 12:00:00 +01:00
home.file.".tmux-sessionizer".source = "${
pkgs.writeShellApplication {
name = ".tmux-sessionizer";
2025-07-07 12:00:00 +01:00
runtimeInputs = with pkgs; [
tmux
];
2025-07-07 12:00:00 +01:00
text = ''
set +o errexit
set +o nounset
2025-07-07 12:00:00 +01:00
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
2025-07-07 12:00:00 +01:00
return
fi
2025-07-07 12:00:00 +01:00
tmux new-window -d -n scratch
nvim .
clear
'';
}
}/bin/.tmux-sessionizer";
2025-07-07 12:00:00 +01:00
xdg.configFile."tmux-sessionizer/tmux-sessionizer.conf".text = ''
TS_SEARCH_PATHS=(${builtins.concatStringsSep " " cfg.searchPaths})
'';
};
}