Running commands on VSCode multiple terminal setup

Viewed 99

I am using VSCode with multiple editors and multiple terminals. I ideally would like to run code in the terminal that is currently visible. Using the macros library by geddski I came close to a solution but could not figure out how to finalise the process.

settings.json

"macros": {  // Note: this requires macros extension by publisher:"geddski" 
"runSelectedInFocusedTerminal": [
"editor.action.clipboardCopyAction",
"workbench.action.terminal.focus",
"workbench.action.terminal.paste",
"workbench.action.focusActiveEditorGroup",
"cursorDown"
]
}

keybindings.json

{
    "key": "ctrl+]",
    "command": "macros.runSelectedInFocusedTerminal",
    "when": "editorTextFocus && editorLangId == 'python' && resourceExtname == '.py'"
}

This macro successfully copies the line or the selected text onto the terminal but it does not run it and go back to the visible editor as I would like.

I also have the ctrl+enter trick from this post: this SO post. However this runs the code in the first terminal I opened using this shortcut and not the visible terminal so it is not a viable solution for using terminals effectively on a multi terminal setup.

0 Answers
Related