问题
first steps with building and running C/Cpp with Sublime Text on Ubuntu. I read here and there and I came up with this following working sublime-build:
{
"cmd": ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"name": "Run",
"shell": true,
"cmd": ["gnome-terminal -e 'bash -c \"${file_path}/${file_base_name}; exec bash\"'"]
}
]
}
Are there better approaches especially at keeping the terminal open after execution is completed?
Any help would be appreciated.
Thanks, Luca
回答1:
It works on Ubuntu 14.04
{
"cmd": ["g++", "$file", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++, source.cxx, source.cpp",
"variants":
[
{
"name": "Run",
"shell": true,
"cmd": ["gnome-terminal -e 'bash -c \"${file_path}/${file_base_name};echo;echo; echo Press ENTER to continue; read line;exit; exec bash\"'"]
}
]
}
回答2:
Try chaning from
"cmd": ["gnome-terminal -e 'bash -c \"${file_path}/${file_base_name}; exec bash\"'"]
to
"cmd": ["gnome-terminal -e 'bash -c \"${file_path}/${file_base_name}; echo 'Press ENTER to continue'; read line; exec bash\"'"]
来源:https://stackoverflow.com/questions/20847916/run-a-simple-c-program-with-sublime-text-2-in-external-terminal-on-ubuntu