Reputation: 1122
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.
Upvotes: 10
Views: 21744
Reputation: 652
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
Upvotes: 7
Reputation: 6318
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.
Upvotes: 1
Reputation: 6318
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
Upvotes: 11
Reputation: 207485
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
Upvotes: 7