1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-13 10:13:39 +02:00

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