fix(codetool): incorrect codetool workdir on macOS (#10056)

fix(codetool): run command and cd in same shell on macOS
This commit is contained in:
George·Dong 2025-09-09 10:02:53 +08:00 committed by GitHub
parent 11502edad2
commit 86f9e93e97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -332,14 +332,15 @@ class CodeToolsService {
// macOS - Use osascript to launch terminal and execute command directly, without showing startup command
const envPrefix = buildEnvPrefix(false)
const command = envPrefix ? `${envPrefix} && ${baseCommand}` : baseCommand
// Combine directory change with the main command to ensure they execute in the same shell session
const fullCommand = `cd '${directory.replace(/'/g, "\\'")}' && clear && ${command}`
terminalCommand = 'osascript'
terminalArgs = [
'-e',
`tell application "Terminal"
set newTab to do script "cd '${directory.replace(/'/g, "\\'")}' && clear"
do script "${fullCommand.replace(/"/g, '\\"')}"
activate
do script "${command.replace(/"/g, '\\"')}" in newTab
end tell`
]
break