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.
This commit is contained in:
@@ -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
|
||||
'';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user