From bee1bdc0d28e6f3c18101e6e41d1c2e504fb29cc Mon Sep 17 00:00:00 2001 From: lampon <670205545@qq.com> Date: Sun, 2 Aug 2026 10:32:08 +0800 Subject: [PATCH] =?UTF-8?q?fix=20Windows=20=E5=8A=A0=E8=BD=BDpowershell?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=B2=A1=E6=9C=89=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=85=8D=E7=BD=AEPROFILE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/codux-terminal-pty/src/lib.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/codux-terminal-pty/src/lib.rs b/crates/codux-terminal-pty/src/lib.rs index e5f31910..6cb16339 100644 --- a/crates/codux-terminal-pty/src/lib.rs +++ b/crates/codux-terminal-pty/src/lib.rs @@ -807,12 +807,24 @@ fn build_interactive_login_shell_command(shell: &str, command: Option<&str>) -> ) { builder.args(["-NoLogo", "-NoProfile", "-NoExit"]); builder.args(["-ExecutionPolicy", "Bypass"]); - // -NoProfile skips user profiles, so the Codux shell integration - // (OSC 133 marks) is dot-sourced explicitly when staged. - let hook_prefix = "if ($env:DMUX_PS_HOOK_SCRIPT -and (Test-Path -LiteralPath $env:DMUX_PS_HOOK_SCRIPT)) { . $env:DMUX_PS_HOOK_SCRIPT }; "; + // Keep -NoProfile so we control load order: user profiles first (starship, + // zoxide, etc.), then Codux OSC 133 hook which wraps prompt/ReadLine. + let startup_prefix = concat!( + "foreach ($p in @(", + "$PROFILE.AllUsersAllHosts, ", + "$PROFILE.AllUsersCurrentHost, ", + "$PROFILE.CurrentUserAllHosts, ", + "$PROFILE.CurrentUserCurrentHost", + ")) { ", + "if ($p -and (Test-Path -LiteralPath $p)) { . $p } ", + "}; ", + "if ($env:DMUX_PS_HOOK_SCRIPT -and (Test-Path -LiteralPath $env:DMUX_PS_HOOK_SCRIPT)) { ", + ". $env:DMUX_PS_HOOK_SCRIPT ", + "}; ", + ); let command = match command { - Some(command) => format!("{hook_prefix}{command}"), - None => hook_prefix.to_string(), + Some(command) => format!("{startup_prefix}{command}"), + None => startup_prefix.to_string(), }; builder.args(["-Command", &command]); return builder;