From 416903839370de4dc66e4ce9f09f89303d6e0a67 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Mon, 29 Jul 2024 12:50:05 +0700 Subject: [PATCH] update zellij auto init --- home/programs/zellij.nix | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/home/programs/zellij.nix b/home/programs/zellij.nix index 45b5aa0..a480ffe 100644 --- a/home/programs/zellij.nix +++ b/home/programs/zellij.nix @@ -24,28 +24,32 @@ in # The lib.mkOrder is used to ensure zellij is # autoloaded first after zshenv. programs.zsh.initExtraFirst = lib.mkOrder 50 ( - /*bash*/ '' - ZELLIJ_AUTO_EXIT=true - ZELLIJ_AUTO_ATTACH=${lib.boolToString cfg.autoAttach} - if [[ -z "$ZELLIJ" ]]; then - ZJ_SESSIONS=$(zellij list-sessions --no-formatting) - NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l) - if [ "$NO_SESSIONS" -ge 2 ]; then - SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}') - if [[ -n "''${SELECTED_SESSION// /}" ]]; then - zellij attach -c "$SELECTED_SESSION" + if cfg.autoAttach then + /*bash*/ + '' + if [[ -z "$ZELLIJ" ]]; then + ZJ_SESSIONS=$(zellij list-sessions --no-formatting) + NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l) + if [ "$NO_SESSIONS" -ge 2 ]; then + SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}') + if [[ -n "''${SELECTED_SESSION// /}" ]]; then + zellij attach -c "$SELECTED_SESSION" + else + zellij attach -c --index 0 + fi else - zellij attach -c --index 0 + zellij attach -c fi - else - zellij attach -c - fi - - if [[ "$ZELLIJ_AUTO_EXIT" == "true" ]]; then exit fi - fi - '' + '' + else + /*bash*/ '' + if [[ -z "$ZELLIJ" ]]; then + zellij attach -c default + exit + fi + '' ); home.file.".config/zellij/config.kdl".text = /*kdl*/ ''