.zshrc not included in bash -l

This commit is contained in:
jimmyfraiture
2025-09-04 16:09:22 -07:00
parent 7b7b938053
commit 154fd14d1d
2 changed files with 15 additions and 7 deletions

View File

@@ -106,6 +106,8 @@ use crate::safety::SafetyCheck;
use crate::safety::assess_command_safety;
use crate::safety::assess_safety_for_untrusted_command;
use crate::shell;
use crate::shell::Shell;
use crate::shell::ShellSnapshot;
use crate::turn_diff_tracker::TurnDiffTracker;
use crate::user_instructions::UserInstructions;
use crate::user_notification::UserNotification;
@@ -286,6 +288,7 @@ pub(crate) struct Session {
codex_linux_sandbox_exe: Option<PathBuf>,
user_shell: shell::Shell,
show_raw_agent_reasoning: bool,
shell_snapshot: Option<ShellSnapshot>,
}
/// The context needed for a single turn of the conversation.
@@ -408,6 +411,11 @@ impl Session {
..Default::default()
};
let shell_snapshot = match &default_shell {
Shell::Zsh(zsh) => zsh.shell_snapshot.clone(),
_ => None,
};
// Handle MCP manager result and record any startup failures.
let (mcp_connection_manager, failed_clients) = match mcp_res {
Ok((mgr, failures)) => (mgr, failures),
@@ -476,6 +484,7 @@ impl Session {
codex_linux_sandbox_exe: config.codex_linux_sandbox_exe.clone(),
user_shell: default_shell,
show_raw_agent_reasoning: config.show_raw_agent_reasoning,
shell_snapshot,
});
// Dispatch the SessionConfiguredEvent first and then report any errors.
@@ -948,6 +957,9 @@ impl Session {
impl Drop for Session {
fn drop(&mut self) {
self.interrupt_task();
if let Some(shell_snapshot) = &self.shell_snapshot {
shell::delete_shell_snapshot(&shell_snapshot.path);
}
}
}

View File

@@ -24,12 +24,6 @@ impl ShellSnapshot {
}
}
impl Drop for ShellSnapshot {
fn drop(&mut self) {
delete_shell_snapshot(&self.path);
}
}
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct PowerShellConfig {
exe: String, // Executable name or path, e.g. "pwsh" or "powershell.exe".
@@ -318,8 +312,10 @@ async fn regenerate_zsh_snapshot(
capture_script.push_str(&format!("{profile_sources}; "));
}
let zshrc = home.join(".zshrc");
capture_script.push_str(
"setopt posixbuiltins; export -p; { alias | sed 's/^/alias /'; } 2>/dev/null || true",
&format!("source {}/.zshrc; setopt posixbuiltins; export -p; {{ alias | sed 's/^/alias /'; }} 2>/dev/null || true", zshrc.display()),
);
let output = tokio::process::Command::new(shell_path)
.arg("-lc")