User forums > Using Code::Blocks

Opening a cmd/powershell console in the debug directory for the current project

(1/1)

Tinkerer:
Hello All

Is there a direct UI feature that would open a console of my choice (cmd or Powershell) in the debug directory
of the current project.

I am working with code that is written as a console filter (stdin and stdout) with optional command line options.
Think wc or grep in the Unix world.

I need the console open each time I work on this code so I can running them through tests.

For now the shortest way is right click on the source file get the "Project base path" from the properties
switch over to a console  and cd to the pasted path with \bin\Debug added on.

Looking for alternatives

This work is being done on Windows 11.

PB:
The only way I can think of now is to add a Tool:

1. Use menu Tools/Configure Tools....
2. Click Add in the User-defined tools dialog.
3. In the Edit Tool dialog use for cmd (without quotes): "Cmd" for Name, "cmd" for Executable and "$(TARGET_OUTPUT_DIR)" for Working directory. Leave Launching options at the first choice.

Unfortunately, macros such as $(TARGET_OUTPUT_DIR) may be working only after a build, so perhaps it would be better to hard-code the path in each tool, even if less convenient.

Now you can launch the tool via Tools menu. You can add another tool for PowerShell in the same way.

Unfortunately, I don't think it is possible to assign a keyboard shortcut for a Tool.

There is probably a better way (e.g., with scripting) but even this may be a bit faster than what are you doing now.

Tinkerer:
Thank you PB

That is good enough for me.

Yes you are right that the Macro is not set yet before a build but that is just fine.

<Movie reference>
"Build it and you can go there"
</Movie reference> ;)

Note that you can only have one tool running at one time with this config.
The the last option may work (detached)  but your have to use it right after a rebuild.

That could work for my workflow.  Rebuild each tool and open the console. Then reuse the consoles while
doing the changes.

PB:

--- Quote from: Tinkerer on July 18, 2024, 06:26:41 pm ---Note that you can only have one tool running at one time with this config.

--- End quote ---
I thought you needed just one of the two.

If you need to launch both cmd and ps, you could create a batch file containing this

--- Code: ---start powershell
cmd
--- End code ---
and use the batch file as the Tool's Executable.

Navigation

[0] Message Index

Go to full version