5

I just started using Geany for a week. And always having to hit F9 to build and then hit F5 to run, it just sucks. So is there any way to config Geany so that it'll build and then execute immediately (like F9 in CodeBlocks) ?

Lâm Nguyễn
  • 51
  • 1
  • 3

3 Answers3

2

You can add your own custom commands or even adjust existing ones. Go to Build->Set Build Commands and change the compile command to something like command1 && command 2. The && should cause your POSIX shell to execute command 2 if command 1 was successful. Inside wiki there is a more verbose version of documentation what can be done on "Set Build Commands"

frlan
  • 6,950
  • 3
  • 31
  • 72
1

I know this is old but I just figured out how to do this on Ubuntu Linux.

-Click "Build" in the menu at the top

-At the bottom go to "Set Build Commands"

-Prepend the command in the "Build" section before the command in the "Execute" section.

Execute should look like g++ -Wall -o "%e" "%f" && "./%e".

Here are before and after images.

Default Build Commands

Build and Execute Combined

You should now be able to build and run your program by pressing F5 (default) once or running execute from the build dropdown menu.

  • 1
    [IN WINDOWS 10] When I did this and hit F5, a command prompt icon seemed to flash on and immediately off in the task bar and the compiler menu doesn't seem to show that compilation was even done. Do you know of a solution that works with Windows 10 Geany 1.36? – An0n1m1ty Jun 27 '20 at 09:28
  • I did this for windows.
    Download
    – adarsh Feb 24 '21 at 17:27
0

i did this for windows.

  • donwload git bash for windows (https://git-scm.com/download/win)

  • download mingw c compiler for windows (https://sourceforge.net/projects/tdm-gcc/) simpler way of this,is to simply use mingw bin folder of codeblocks which has the gcc for winodws binaries, to search , go to your codeblocks installed folder and search "gcc.exe" in search bar. set this bin folder as path through in enevirment variables(https://www.java.com/en/download/help/path.html)

  • in geany go to build->set build commands

  • in execute box write \bin\bash -c "gcc %f && time ./a.exe" Example : D:\Downloads\GitBash\bin\bash -c "gcc %f && time ./a.exe"

  • after this , write a source file and hit F5. Your code will compile and on successfull compile it will run

adarsh
  • 135
  • 7