zellij: add config options for autostart

from: https://zellij.dev/documentation/integration.html#fish
This commit is contained in:
Manu [tennox] 2024-04-24 12:34:36 +01:00
parent 4b54a38bb5
commit 7200b8c963

View file

@ -49,15 +49,28 @@ in {
default = false; default = false;
}; };
enableFishIntegration = mkEnableOption "Fish integration (enables both enableFishAutostart and enableFishCompletions)" // { enableFishIntegration = mkEnableOption
default = false; "Fish integration (enables both enableFishAutoStart and enableFishCompletions)"
}; // {
enableFishAutostart = mkEnableOption "autostart zellij in interactive sessions" // { default = false;
default = false; };
};
enableFishCompletions = mkEnableOption "load zellij completions" // { enableFishCompletions = mkEnableOption "load zellij completions" // {
default = false; default = false;
}; };
enableFishAutoStart =
mkEnableOption "autostart zellij in interactive sessions" // {
default = false;
};
autoStartAttachIfSessionExists = mkEnableOption
"If the zellij session already exists, attach to the default session. (requires enableFishAutoStart)"
// {
default = false;
};
autoStartExitShellOnZellijExit = mkEnableOption
"When zellij exits, exit the shell as well. (requires enableFishAutoStart)"
// {
default = false;
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -83,15 +96,22 @@ in {
eval "$(${zellijCmd} setup --generate-auto-start zsh)" eval "$(${zellijCmd} setup --generate-auto-start zsh)"
''); '');
programs.fish.interactiveShellInit = mkIf (cfg.enableFishIntegration || cfg.enableFishAutostart || cfg.enableFishCompletions) home.sessionVariables = {
(mkOrder 200 ( ZELLIJ_AUTO_ATTACH =
(if cfg.enableFishIntegration || cfg.enableFishCompletions then '' if cfg.autoStartAttachIfSessionExists then "true" else "false";
ZELLIJ_AUTO_EXIT =
if cfg.autoStartExitShellOnZellijExit then "true" else "false";
};
programs.fish.interactiveShellInit = mkIf (cfg.enableFishIntegration
|| cfg.enableFishAutoStart || cfg.enableFishCompletions) (mkOrder 200
((if cfg.enableFishIntegration || cfg.enableFishCompletions then ''
eval (${zellijCmd} setup --generate-completion fish | string collect) eval (${zellijCmd} setup --generate-completion fish | string collect)
'' else "") + '' else
(if cfg.enableFishIntegration || cfg.enableFishAutostart then '' "") + (if cfg.enableFishIntegration || cfg.enableFishAutoStart then ''
eval (${zellijCmd} setup --generate-auto-start fish | string collect) eval (${zellijCmd} setup --generate-auto-start fish | string collect)
'' else "") '' else
)); "")));
}; };
} }