update zellij auto init

This commit is contained in:
Tigor Hutasuhut 2024-07-29 12:50:05 +07:00
parent 09202966e0
commit 4169038393

View file

@ -24,28 +24,32 @@ in
# The lib.mkOrder is used to ensure zellij is # The lib.mkOrder is used to ensure zellij is
# autoloaded first after zshenv. # autoloaded first after zshenv.
programs.zsh.initExtraFirst = lib.mkOrder 50 ( programs.zsh.initExtraFirst = lib.mkOrder 50 (
/*bash*/ '' if cfg.autoAttach then
ZELLIJ_AUTO_EXIT=true /*bash*/
ZELLIJ_AUTO_ATTACH=${lib.boolToString cfg.autoAttach} ''
if [[ -z "$ZELLIJ" ]]; then if [[ -z "$ZELLIJ" ]]; then
ZJ_SESSIONS=$(zellij list-sessions --no-formatting) ZJ_SESSIONS=$(zellij list-sessions --no-formatting)
NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l) NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l)
if [ "$NO_SESSIONS" -ge 2 ]; then if [ "$NO_SESSIONS" -ge 2 ]; then
SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}') SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}')
if [[ -n "''${SELECTED_SESSION// /}" ]]; then if [[ -n "''${SELECTED_SESSION// /}" ]]; then
zellij attach -c "$SELECTED_SESSION" zellij attach -c "$SELECTED_SESSION"
else
zellij attach -c --index 0
fi
else else
zellij attach -c --index 0 zellij attach -c
fi fi
else
zellij attach -c
fi
if [[ "$ZELLIJ_AUTO_EXIT" == "true" ]]; then
exit exit
fi fi
fi ''
'' else
/*bash*/ ''
if [[ -z "$ZELLIJ" ]]; then
zellij attach -c default
exit
fi
''
); );
home.file.".config/zellij/config.kdl".text = /*kdl*/ '' home.file.".config/zellij/config.kdl".text = /*kdl*/ ''