From 258fc4b401218b82e7cba6aec96bedd789e731c2 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 14 Jan 2026 08:58:10 +0000 Subject: [PATCH] feat: add sourcing of rc files to shell snapshot (#9150) --- codex-rs/core/src/shell_snapshot.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/codex-rs/core/src/shell_snapshot.rs b/codex-rs/core/src/shell_snapshot.rs index b27548756..f16e1f03d 100644 --- a/codex-rs/core/src/shell_snapshot.rs +++ b/codex-rs/core/src/shell_snapshot.rs @@ -135,7 +135,13 @@ async fn run_shell_script_with_timeout( } fn zsh_snapshot_script() -> &'static str { - r##"print '# Snapshot file' + r##"if [[ -n "$ZDOTDIR" ]]; then + rc="$ZDOTDIR/.zshrc" +else + rc="$HOME/.zshrc" +fi +[[ -r "$rc" ]] && . "$rc" +print '# Snapshot file' print '# Unset all aliases to avoid conflicts with functions' print 'unalias -a 2>/dev/null || true' print '# Functions' @@ -156,7 +162,10 @@ export -p } fn bash_snapshot_script() -> &'static str { - r##"echo '# Snapshot file' + r##"if [ -z "$BASH_ENV" ] && [ -r "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" +fi +echo '# Snapshot file' echo '# Unset all aliases to avoid conflicts with functions' unalias -a 2>/dev/null || true echo '# Functions' @@ -180,7 +189,10 @@ export -p } fn sh_snapshot_script() -> &'static str { - r##"echo '# Snapshot file' + r##"if [ -n "$ENV" ] && [ -r "$ENV" ]; then + . "$ENV" +fi +echo '# Snapshot file' echo '# Unset all aliases to avoid conflicts with functions' unalias -a 2>/dev/null || true echo '# Functions'