Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 38 additions & 12 deletions packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1285,20 +1285,46 @@ export namespace SessionPrompt {
const shell = process.env["SHELL"] ?? "bash"
const shellName = path.basename(shell)

const scripts: Record<string, string> = {
nu: input.command,
fish: `eval "${input.command}"`,
const invocations: Record<string, { args: string[] }> = {
nu: {
args: ["-c", input.command],
},
fish: {
args: ["-c", input.command],
},
zsh: {
args: [
"-c",
"-l",
`
[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
${input.command}
`
],
},
bash: {
args: [
"-c",
"-l",
`
[[ -f ~/.bashrc ]] && source ~/.bashrc >/dev/null 2>&1 || true
${input.command}
`,
],
},
// Fallback: any shell that doesn't match those above
"": {
args: [
"-c",
"-l",
`${input.command}`,
],
},
}

const script =
scripts[shellName] ??
`[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
[[ -f ~/.bashrc ]] && source ~/.bashrc >/dev/null 2>&1 || true
eval "${input.command}"`

const isFishOrNu = shellName === "fish" || shellName === "nu"
const args = isFishOrNu ? ["-c", script] : ["-c", "-l", script]
const matchingInvocation = invocations[shellName] ?? invocations[""];
const args = matchingInvocation?.args

const proc = spawn(shell, args, {
cwd: Instance.directory,
Expand Down
Loading