70 lines
1.8 KiB
Nix
70 lines
1.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.cli.tmux-sessionizer;
|
|
in
|
|
{
|
|
options.cli.tmux-sessionizer = {
|
|
enable = mkEnableOption "Enable tmux-sessionizer";
|
|
enableDmenuIntegration = mkEnableOption "Enable dmenu integration";
|
|
|
|
directories = mkOption {
|
|
default = [ config.home.homeDirectory ];
|
|
type = types.listOf types.str;
|
|
description = "List of directories for tmux-sessionizer to use.";
|
|
};
|
|
};
|
|
|
|
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)
|
|
|
|
${pkgs.coreutils}/bin/nohup st -e tmux-sessionizer "$selected" >/dev/null 2>&1 &
|
|
'';
|
|
}
|
|
));
|
|
|
|
xdg.configFile = {
|
|
"tmux-sessionizer/default".source = "${
|
|
pkgs.writeShellApplication {
|
|
name = ".tmux-sessionizer";
|
|
|
|
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 .
|
|
clear
|
|
'';
|
|
}
|
|
}/bin/.tmux-sessionizer";
|
|
|
|
"tmux-sessionizer/directories".text = builtins.concatStringsSep "\n" cfg.directories;
|
|
};
|
|
};
|
|
}
|