CLion bind shortcut to run command in terminal - c++

I currently have a setup which can compile and run the currently focused file tab through a shortcut. I achieve this through the External Tool feature in which I assigned a custom bash file with a couple of commands to that keypress.
But this causes the output in the Run tab to clear each time I run my code. I want to preserve the output. This can be done if the bash file that I run through the External Tools can instead run as a command in the terminal when I press the shortcut.
Can this be done?

Run tab will remain if you uncheck the "Open console for output" in the External tool configuration window. It won't open the tool's output then, though.

Related

how do I run my code on cmd instead of vscode's internal terminal

everyone. I'm kind of new in this field. So bear with it. I'll try to be as specific as I can:
let's say when I run a code(c++ file) in VScode it runs that code on VScode's internal terminal..like this => VScode
but I want that code to run on my Window's CMD like "CodeBlocks" software. Like this => CodeBlocks
but I don't know how to do it in VScode. I mean, when I click on 'run' button it should execute that code on CMD. I tried many ways but it's not working. Help please and thanks in advance.
VSCode has a built-in terminal. That is why in the first case(first image in your question) you see the output as it is. If you don't want to use the built in terminal provided by VSCode then i suggest you open a standalone/separate terminal. And then cd into the project you want to build/compile and then compile the program from there.
Basically, open a terminal externally then go(cd) to your workspace folder and finally compile and run in the external terminal.

How to run a program from VSCode in Windows CMD terminal? [duplicate]

I have a Console application open in VS Code. When I press Ctrl-F5, the output of my program is displayed in a DEBUG CONSOLE window, along with other text.
How do I get Visual Studio code to launch my program in a new console window?
As documented here this can be achieved using this setting:
"console": "externalTerminal"
The settings file is in the solution directory: .vscode/launch.json .
When you're just using Tasks and not Launchers, you can follow the advice here.
For me on Linux, I changed my shell command in VSCode from command to gnome-terminal -e command. That did the trick; that's all I had to do.
Note that if you do this you can get rid of the presentation option set from your task.

How can I change the default behaviour of "Terminal: Explorer Kind" in VS Code Settings? [duplicate]

I have a Console application open in VS Code. When I press Ctrl-F5, the output of my program is displayed in a DEBUG CONSOLE window, along with other text.
How do I get Visual Studio code to launch my program in a new console window?
As documented here this can be achieved using this setting:
"console": "externalTerminal"
The settings file is in the solution directory: .vscode/launch.json .
When you're just using Tasks and not Launchers, you can follow the advice here.
For me on Linux, I changed my shell command in VSCode from command to gnome-terminal -e command. That did the trick; that's all I had to do.
Note that if you do this you can get rid of the presentation option set from your task.

visualstudio code C++ terminal for output

When debugging a C++ application on linux using, VisualStudio Code, an instance of an external terminal window is opened, and the applications console appears on this window.
This is a bit inconvenient because I have to change windows to see the output when debugging.
Is it possible to have the output to appear in a "pane" like the built in terminal appears (like the one started by CTRL-`)? If so how can this be done?
I have tried changing the launch file's "externalConsole" from true to false but this didn't work.
You need to use the Integrated Terminal.
View > Toggle Integrated Terminal
In launch.json set "externalConsole": false,.
Then the output goes to the Debug Console.
But instead of things looking like:
Hello World!
It will show up as:
#"Hello World!\r\n"
I have read that they still work in proper terminal support for the terminal inside VSCode. I think that also explains why it defaults now to the external terminal.

Easy way to run command line programs C++ - Windows 7

I am trying to find an easier way to test my command line application. It has arguments so I run it from a command prompt. My process is this:
Build
Go to the output
Open command prompt
Change directory
Run it
There has to be an easier way not only to debug but to open a command prompt in the current folder.
Thank you for your time.
If you go to the project properties, Debugging settings, you can set the working directory and parameters. If you use the same parameters all of the time, you can enter those in on that screen as well. Then just F5 or Ctrl+F5 to run.
Set a breakpoint at the end of the code to keep it from going away after it is done.
See Debugging with command-line parameters in Visual Studio
Alternatively, you should be able to use a shell script (or Python os.system()) to automate some of those steps.
To open a command prompt in the current directory using explorer, you can shift+right click->Open Command Window Here. That will save a little time.
If you're using Visual Studio, pressing F5 will run the code in the debugger, and Ctrl+F5 will run the code normally. Just remember to include a cin.get() statement at the end or the terminal window will close before you can read the output.
Other IDEs should have similar functions. Check in the Run or Debug menu.
EDIT: Sorry, didn't see that you're asking about running it with arguments. In VS, in Project Properties there are the Debugging settings. Within that, there is a field called Command Arguments. These will get passed to the application when you run it from within VS.
In project properties under debugging you can set the command line arguments (and environment variables) when debugging,
There is an extension called PowerCommands for Visual Studio 2010 that can be installed from Tools -> Extension Manager. It includes a Open Containing Folder and Open Command Prompt functionality that gets added to your right-click menu in the Solution Explorer.