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 = {
|
programs.bash = {
|
||||||
enable = true;
|
enable = true;
|
||||||
interactiveShellInit = ''
|
interactiveShellInit = ''
|
||||||
if [[ $- == *i* ]] && [[ -z "''${M3_SHELL_TO_NU:-}" ]]; then
|
# Interactive bash -> nushell, unless started deliberately from
|
||||||
export M3_SHELL_TO_NU=1
|
# nu/bash (parent check — an exported env marker would leak into
|
||||||
exec ${pkgs.nushell}/bin/nu --login
|
# 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
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user