-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support external terminal option #1992
Comments
HI @connor4312 👋 Any idea about that? |
Sure, a PR is welcome. Note this is actually implemented in https://github.com/microsoft/vscode/tree/main/extensions/npm |
I managed to have external processes (i.e. launched from outside vscode integrated terminals) auto-attach to vscode debug sessions by hacking with it a bit. Step 1:Create an automatic task that exports the debugging env vars. .vscode/tasks.json {
"version": "2.0.0",
"tasks": [
{
"label": "Capture Debug Vars",
"type": "shell",
"command": "bash",
"args": [".vscode/captureDebugVars.sh"],
"problemMatcher": [],
"options": {
"env": {
"ENV_FILE": "${workspaceFolder}/.env.local" // set any file you want
}
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
} .vscode/captureDebugVars.sh #!/usr/bin/env bash
set -euo pipefail
# Check if required environment variables are set
if [[ -z "${ENV_FILE:-}" ]]; then
echo "You forgot to set ENV_FILE"
exit 1
fi
if [[ -z "${VSCODE_INSPECTOR_OPTIONS:-}" || -z "${NODE_OPTIONS:-}" ]]; then
echo "VS Code has not defined VSCODE_INSPECTOR_OPTIONS or NODE_OPTIONS"
exit 1
fi
# Load current configuration if the file exists
declare -A env
if [[ -f "$ENV_FILE" ]]; then
while IFS='=' read -r key value; do
env["$key"]="$value"
done < "$ENV_FILE"
fi
# Merge new configuration
env["NODE_OPTIONS"]="${NODE_OPTIONS}"
env["VSCODE_INSPECTOR_OPTIONS"]="${VSCODE_INSPECTOR_OPTIONS}"
# Write the new configuration back to the file
{
for key in "${!env[@]}"; do
echo "$key=${env[$key]}"
done
} > "$ENV_FILE"
echo "Environment variables captured to $ENV_FILE" Step 2Find a way to automatically load the env vars into your terminal. I use and recommend direnv: .envrc source .env.local # or whatever you used as ENV_FILE on step 1 With that in place, all your scripts will be automatically debugged in vscode as long as vscode is running and you have opened it before running your external script. |
Is your feature request related to a problem? Please describe.
The issue
I was trying to find a way to run the debug session whitin an external terminal (such as Warp / iTerm2) - based on the default terminal setting, for MacOS it is
terminal.external.osxExec
.Describe the feature you'd like
My suggestion
A nice checkbox for enabling this feature, so once I'm hitting on the new debug session (by the code lens on the
package.json
OR with any menu exists, such as theNPM SCRIPTS
) - the new debug session would trigger commands over my default terminal.Screenshots
The text was updated successfully, but these errors were encountered: