Skip to content

Instantly share code, notes, and snippets.

@andrewodri
Created September 12, 2023 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewodri/d898371e1b3337e649d4cc3e7cc141a3 to your computer and use it in GitHub Desktop.
Save andrewodri/d898371e1b3337e649d4cc3e7cc141a3 to your computer and use it in GitHub Desktop.
VSCode task to close an external Terminal on macOS when debugging in Node
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "npm-run-build",
"group": "build",
"type": "shell",
"hide": false,
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true,
},
"command": "${env:NVM_DIR}/nvm-exec",
"args": [ "npm", "run", "build" ],
"options": {
"cwd": "${workspaceFolder}",
},
},
// tell application "Terminal"
// set theWindows to windows
// repeat with aWindow in theWindows
// if (history of selected tab of aWindow) contains "Waiting for the debugger to disconnect..." then
// close aWindow without saving
// end if
// end repeat
// end tell
{
"label": "close-terminal",
"group": "none",
"type": "shell",
"hide": true,
"presentation": {
"echo": false,
"reveal": "never",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true,
},
"osx": {
"command": "osascript",
"args": [
"-e", "tell application \"Terminal\"",
"-e", "set theWindows to windows",
"-e", "repeat with aWindow in theWindows",
"-e", "if (history of selected tab of aWindow) contains \"Waiting for the debugger to disconnect...\" then",
"-e", "close aWindow without saving",
"-e", "end if",
"-e", "end repeat",
"-e", "end tell",
],
},
"options": {
"cwd": "${workspaceFolder}",
},
},
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment