zellij: option to enable completions without enabling autostart

bit complicated to do this without breaking changes to the existing
`enableFishIntegration`... 🤔
This commit is contained in:
Manu [tennox] 2024-04-23 20:42:11 +01:00
parent 96a643b2c9
commit 4b54a38bb5

View file

@ -49,7 +49,13 @@ in {
default = false;
};
enableFishIntegration = mkEnableOption "Fish integration" // {
enableFishIntegration = mkEnableOption "Fish integration (enables both enableFishAutostart and enableFishCompletions)" // {
default = false;
};
enableFishAutostart = mkEnableOption "autostart zellij in interactive sessions" // {
default = false;
};
enableFishCompletions = mkEnableOption "load zellij completions" // {
default = false;
};
};
@ -77,10 +83,15 @@ in {
eval "$(${zellijCmd} setup --generate-auto-start zsh)"
'');
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration
(mkOrder 200 ''
eval (${zellijCmd} setup --generate-auto-start fish | string collect)
eval (${zellijCmd} setup --generate-completion fish | string collect)
'');
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)
'' else "") +
(if cfg.enableFishIntegration || cfg.enableFishAutostart then ''
eval (${zellijCmd} setup --generate-auto-start fish | string collect)
'' else "")
));
};
}