2025-04-23 14:19:05 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2025-05-03 16:50:27 +01:00
|
|
|
cfg = config.cli.tmux-sessionizer;
|
2025-04-23 14:19:05 +01:00
|
|
|
in
|
|
|
|
{
|
2025-05-03 16:50:27 +01:00
|
|
|
options.cli.tmux-sessionizer = {
|
2025-04-23 14:19:05 +01:00
|
|
|
enable = mkEnableOption "Enable tmux-sessionizer";
|
2025-05-30 12:13:19 +01:00
|
|
|
enableDmenuIntegration = mkEnableOption "Enable dmenu integration";
|
2025-04-23 14:19:05 +01:00
|
|
|
|
2025-07-07 12:00:00 +01:00
|
|
|
searchPaths = mkOption {
|
2025-04-23 14:19:05 +01:00
|
|
|
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-04-23 14:19:05 +01:00
|
|
|
};
|
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.
|
2025-04-23 14:19:05 +01:00
|
|
|
};
|
2025-04-23 14:19:05 +01:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = with pkgs; [
|
|
|
|
tmux-sessionizer
|
2025-07-07 12:00:00 +01:00
|
|
|
];
|
2025-04-23 14:19:05 +01:00
|
|
|
|
2025-07-07 12:00:00 +01:00
|
|
|
home.file.".tmux-sessionizer".source = "${
|
|
|
|
pkgs.writeShellApplication {
|
|
|
|
name = ".tmux-sessionizer";
|
2025-04-23 14:19:05 +01:00
|
|
|
|
2025-07-07 12:00:00 +01:00
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
tmux
|
|
|
|
];
|
2025-04-23 14:19:05 +01:00
|
|
|
|
2025-07-07 12:00:00 +01:00
|
|
|
text = ''
|
|
|
|
set +o errexit
|
|
|
|
set +o nounset
|
2025-04-23 14:19:05 +01:00
|
|
|
|
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-04-23 14:19:05 +01:00
|
|
|
|
2025-07-07 12:00:00 +01:00
|
|
|
return
|
|
|
|
fi
|
2025-04-23 14:19:05 +01:00
|
|
|
|
2025-07-07 12:00:00 +01:00
|
|
|
tmux new-window -d -n scratch
|
|
|
|
nvim .
|
|
|
|
clear
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
}/bin/.tmux-sessionizer";
|
2025-04-23 14:19:05 +01:00
|
|
|
|
2025-07-07 12:00:00 +01:00
|
|
|
xdg.configFile."tmux-sessionizer/tmux-sessionizer.conf".text = ''
|
|
|
|
TS_SEARCH_PATHS=(${builtins.concatStringsSep " " cfg.searchPaths})
|
2025-07-09 00:23:48 +01:00
|
|
|
TS_SESSION_COMMANDS=(nvim .)
|
2025-07-07 12:00:00 +01:00
|
|
|
'';
|
2025-04-23 14:19:05 +01:00
|
|
|
};
|
|
|
|
}
|