zellij: fix zellij failed to start when autoAttach is true when multiple

zellij sessions are running
This commit is contained in:
Tigor Hutasuhut 2024-07-25 22:46:32 +07:00
parent a4d757079b
commit b04e84649a

View file

@ -6,11 +6,28 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.zellij.enable = true; programs.zellij.enable = true;
programs.zsh.initExtraFirst = lib.mkOrder 20000 ( # Uses initExtraFirst instead of initExtra
# to avoid loading of zsh plugins before zellij loads.
#
# Let zsh inside zellij that loads zsh plugins.
#
# The lib.mkOrder is used to ensure zellij is
# autoloaded first after zshenv.
programs.zsh.initExtraFirst = lib.mkOrder 50 (
/*bash*/ '' /*bash*/ ''
ZELLIJ_AUTO_EXIT=true ZELLIJ_AUTO_EXIT=true
ZELLIJ_AUTO_ATTACH=${toString cfg.autoAttach} ZELLIJ_AUTO_ATTACH=${lib.boolToString cfg.autoAttach}
eval "$(zellij setup --generate-auto-start zsh)" if [[ -z "$ZELLIJ" ]]; then
if [[ "$ZELLIJ_AUTO_ATTACH" == "true" ]]; then
zellij attach --index 0 -c
else
zellij
fi
if [[ "$ZELLIJ_AUTO_EXIT" == "true" ]]; then
exit
fi
fi
'' ''
); );