From 7601583928edf20653383b261828b6c8257d2d59 Mon Sep 17 00:00:00 2001 From: m3ta-chiron Date: Mon, 31 Aug 2026 09:56:13 +0200 Subject: [PATCH] fix(shell): exec into nushell by parent process, not env marker The exported M3_SHELL_TO_NU marker leaked into programs started from nu (zellij, zed, herdr), keeping their spawned terminals in bash. Decide via /proc/$PPID/comm instead: interactive bash whose parent is neither nu nor bash execs into nu; a deliberate 'bash' started from nu/bash stays bash. Non-interactive bash (ssh command exec, Mosh app bootstrap, see 765ae15) is still covered by the $- == *i* check. --- hosts/common/default.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 956daa9..d7c6e64 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -80,9 +80,17 @@ programs.bash = { enable = true; interactiveShellInit = '' - if [[ $- == *i* ]] && [[ -z "''${M3_SHELL_TO_NU:-}" ]]; then - export M3_SHELL_TO_NU=1 - exec ${pkgs.nushell}/bin/nu --login + # Interactive bash -> nushell, unless started deliberately from + # nu/bash (parent check — an exported env marker would leak into + # zellij/zed/herdr children). Non-interactive bash (ssh command + # exec, Mosh app bootstrap) stays bash. + if [[ $- == *i* ]]; then + parent="" + [[ -r /proc/$PPID/comm ]] && IFS= read -r parent < /proc/$PPID/comm + if [[ "$parent" != "nu" && "$parent" != "bash" ]]; then + exec ${pkgs.nushell}/bin/nu --login + fi + unset parent fi ''; };