Search code examples
csublimetext3gnome-terminal

Show C build results in Linux terminal with Sublime Text 3


I'm using Sublime Text 3 for C programming. I want to compile and run my programs in the gnome terminal using a keybinding or something like that instead of the ST3 console (like CodeBlocks does). How can I do it?


Solution

  • Click Tools->Build System->New build system to add a new build system, copy following code:

    {
    "cmd" : ["gnome-terminal -x bash -c \"gcc $file_name -o ${file_base_name} -lm -Wall; ./${file_base_name}; exec bash\""],
    "selector" : "source.c",
    "shell":true,
    "working_dir" : "$file_path"
    }
    

    Save this file.

    Then click Tools->Build System to choose the newly stored build system. Every time you press "Ctrl+B", the keybinding of Tools->build, it will run gnome-terminal and compile&run your program automatically.