Search code examples
c++terminaltext-editorclion

Open Clion from terminal


I've been trying to set a path to Clion directory in my computer in order to open this program with a command in terminal, but it didn't worked.

If you read this and asked yourself: "what?". I want to start a C++ project like I did with a normal text editor(I used to write codes with gedit).

I want something like, make a hello world:

Clion helloWorld.cpp &

And it will open a new project, named helloWorld, and then I can write down the code.

If it is impossible to do that, sorry.


Solution

  • Start CLion using the GUI interface, then start Terminal and run the following to find what process is running:

    ps -ae| grep lion
    

    Output

    57257 ??         0:20.45 /Applications/CLion.app/Contents/MacOS/clion
    57434 ttys000    0:00.00 grep lion
    

    So the command I need to use, in my case, to start CLion from the command line is:

    /Applications/CLion.app/Contents/MacOS/clion
    

    Then you need to pass the directory containing your project, so you could make a function like this:

    function CLion {  /Applications/CLion.app/Contents/MacOS/clion "$1"; }
    

    Then you can just type:

    Clion ~/CLionProjects/someProject