Open Clion from terminal
Asked Answered
P

4

10

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.

Precontract answered 5/1, 2017 at 12:25 Comment(7)
Please paste what have you tried so farCosentino
I tried to set a sym link, with ln command and I guess that kind of messed up my notebook. I kind of created a /home/userName/userName/(other directories). I also tried to add export lines in the end of my ~./profile archivePrecontract
"Add "{installation home}/bin" to your PATH environment variable so that you may start CLion from any directory." This is in the installation.txt. But I couldn't do it.Precontract
If you use bash try adding PATH=$PATH:{installation home}/bin at the and of your bash.rc in your home folderCosentino
I've read something that this is a temporally solution and I should add that in a ~/.profile filePrecontract
Where did you install CLion, e.g. did you install in $HOME/CLion or in /opt or somewhere else?Caveat
/home/gabriel/Documents/clion-2016.3.2 is where my Clion is. And I only ./clion.sh at /home/gabriel/Documents/clion-2016.3.2/bin folder in terminalPrecontract
C
7

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
Caveat answered 5/1, 2017 at 12:38 Comment(7)
ps -ae| grep lion gives me no Output but, if I open clion.sh, manually, i get this as Output 6342 ? 00:00:00 clion.shPrecontract
Did you start CLion via the GUI first? And as the same user? Try ps -aef | grep -i CLionCaveat
My output gabriel 8186 5484 0 10:59 pts/2 00:00:00 /bin/sh ./clion.sh and gabriel 8281 8241 0 10:59 pts/2 00:00:00 /home/gabriel/Documents/clion-2016.3.2/bin/fsnotifier64 which one I use?Precontract
I think we must have installed CLion differently. I used homebrew to install mine very simply with brew install Caskroom/cask/clion so if you installed from source, your setup may differ. I'll ask some questions in a moment.Caveat
It worked, I used /home/userName/Documents/clion-2016.3.2/bin/clion.shPrecontract
Use locate clion.sh on UbuntuLate
Why not just put it in an alias instead of a wrapper function? alias clion="/Applications/CLion.app/Contents/MacOS/clion"Fancywork
B
11

In researching this question, I just discovered that there is an officially supported method for doing this is via CLion's Tools|Create Command Line Launcher... menu item.

Full details are posted here: https://www.jetbrains.com/help/clion/working-with-the-ide-features-from-command-line.html

Breathed answered 30/1, 2019 at 12:39 Comment(0)
C
7

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
Caveat answered 5/1, 2017 at 12:38 Comment(7)
ps -ae| grep lion gives me no Output but, if I open clion.sh, manually, i get this as Output 6342 ? 00:00:00 clion.shPrecontract
Did you start CLion via the GUI first? And as the same user? Try ps -aef | grep -i CLionCaveat
My output gabriel 8186 5484 0 10:59 pts/2 00:00:00 /bin/sh ./clion.sh and gabriel 8281 8241 0 10:59 pts/2 00:00:00 /home/gabriel/Documents/clion-2016.3.2/bin/fsnotifier64 which one I use?Precontract
I think we must have installed CLion differently. I used homebrew to install mine very simply with brew install Caskroom/cask/clion so if you installed from source, your setup may differ. I'll ask some questions in a moment.Caveat
It worked, I used /home/userName/Documents/clion-2016.3.2/bin/clion.shPrecontract
Use locate clion.sh on UbuntuLate
Why not just put it in an alias instead of a wrapper function? alias clion="/Applications/CLion.app/Contents/MacOS/clion"Fancywork
B
7

For Mac users, you need to add following row in ~/.bash_profile:

alias clion='open -na "CLion.app" --args "$@"'

Then from the terminal you can run CLion:

clion /path-to-your-project
Baseburner answered 31/10, 2020 at 5:5 Comment(2)
For some reason this does not open new app instance...Tetrabasic
It should be noted that with new OS changes you might need to add that line into ~/.zshrc instead of ~/.bash_profile. Then, remember to source the file (either . ~/.zshrc or source ~/.zshrc, or simply closing and reopening/loading the terminal).Boatload
B
1

If you use JetBrains Toolbox to manage your CLion (or other IntelliJ) apps like I do, you'll find that Toolbox installs CLion with a versioned pathname. This means every time you update CLion, the path to the clion.sh launcher script changes.

For Linux environments, you can use the following in your ~/.bash_profile to handle this:

alias clion="`find ~/.local -iname clion.sh | head -1` >/dev/null &" #Linux

or

alias clion='open -n "$(IFS=$'\n' && find "${HOME}/Library/Application Support/JetBrains/Toolbox/apps/CLion" -iname clion.app | head -1)"' #Mac OS X

If you upgrade your CLion you can restart your terminal or just run . ~/.bashrc to update the clion alias.

Breathed answered 30/1, 2019 at 12:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.