Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can preLaunchTask and launch start within the same terminal in VSCode?

I am debugging my CPP code with VSCode. I need to use a preLaunchTask to set my environment before my code run. So my code should run after preLaunchTask right in the same terminal. But it start in two different terminal now. How can I do with this?

And btw how can I start the process in the same terminal next time? Some process will start another terminal next time, I am confuse.

My preLaunchTask:

{
    "label": "source_setup",
    "type": "shell",
    "command": "source ./devel/setup.zsh && export ROS_MASTER_URI=http://localhost:11311/ "
},
like image 437
HaoQChen Avatar asked Aug 16 '19 02:08

HaoQChen


People also ask

What is preLaunchTask vscode?

preLaunchTask - to launch a task before the start of a debug session, set this attribute to the label of a task specified in tasks. json (in the workspace's . vscode folder). Or, this can be set to ${defaultBuildTask} to use your default build task.

What is launch json in vscode?

A launch. json file is used to configure the debugger in Visual Studio Code. Visual Studio Code generates a launch. json (under a . vscode folder in your project) with almost all of the required information.

Where is launch json in vscode?

The launch. json file is located in a . vscode folder in your workspace (project root folder).

How do you start a Debug session in VS code?

Switch to the Run and Debug view (Ctrl+Shift+D) and select the create a launch. json file link. VS Code will let you select an "debugger" in order to create a default launch configuration. Pick "Mock Debug".


Video Answer


1 Answers

As stated by @isidorn in this vscode GitHub issue this feature is currently not yet supported. In the meantime, people can achieve the desired behaviour by adding the following code to their .bashrc

# Source ros setup.bash if present
if [ -f '../devel/setup.bash' ]; then . "../devel/setup.bash";fi
like image 174
arcety Avatar answered Sep 22 '22 12:09

arcety