refactor: move zellij to shared module

This commit is contained in:
Gerg-L 2025-05-24 23:44:44 -04:00
parent 362b9dda0f
commit 5b9d021b59
Signed by: gerg-l
SSH key fingerprint: SHA256:FPYDHIkvMocr4wdmZXpgpJjsb2Tw6rASs2ISPbOb0KI
3 changed files with 39 additions and 18 deletions

View file

@ -0,0 +1,39 @@
{
lib,
pkgs,
config,
}:
{
options.local.zellij = lib.mkEnableOption "zellij" // {
default = true;
};
config = lib.mkIf config.local.zellij {
local.packages = {
inherit (pkgs) zellij;
};
programs.zsh.interactiveShellInit =
let
monitorScript = pkgs.replaceVarsWith {
src = ./monitor.ps;
replacements = builtins.mapAttrs (_: lib.getExe) {
inherit (pkgs) perl xdotool;
};
isExecutable = true;
};
in
''
if [[ -z "$ZELLIJ" ]]; then
if [[ -n "$SSH_TTY" ]]; then
zellij attach -c "SSH@$USER"
else
MONITOR="$(${monitorScript} || true)"
zellij attach -c "''${MONITOR:+"$MONITOR@"}$USER"
fi
exit
fi
'';
};
}