c++ - When using sublime text 2, how can I have the built executable run in terminal? -


i using sublime text under ubuntu. every sublime text user knows, can build .cpp file in sublime using tools->build, , run using tools->run. convenient!

the problem executable can run inside local window @ bottom of sublime, without ability interactively accept user's input.

i changed cmd line in c++.sublimetext this:

"cmd": ["x-terminal-emulator","-e", "g++ '${file}' -o '${file_path}/${file_base_name}'    && '${file_path}/${file_base_name}'"]   

although typing

"x-terminal-emulator -e executable_file_path_and_name"

in terminal work, failed in sublime. bug in sublime?

any way make run in terminal?

it's because terminal program closes compiler or c++ program quits (and since compiler quits after failed compilation, you'll never see error messages). , because terminal doesn't know how handle &&.

use this:

"cmd": ["x-terminal-emulator","-e",    "bash -c \"g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}' ; read -p 'press key continue...'\""], 

Comments