Run a simple C program with Sublime Text 2 in external terminal on Ubuntu

佐手、 提交于 2019-12-12 06:29:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!