Opening file from command line

Hi,

Is there a way to open a file from the command line into a _currently_ running CLion session?  I.e. do the equivalent of 'Navigate'/'Files' from a terminal window.

Thanks,
Philippe.

1
7 comments

Hi Philippe.

If you perform the command described at https://www.jetbrains.com/idea/help/working-with-intellij-idea-features-from-command-line.html in “Opening file in the editor” (replace IntellijJ IDEA with CLion, of course) the file is opened in the existing window if the desired project is already opened.

0
Avatar
Permanently deleted user

Hi Anna,

When I try the recipe (with CLion 1.2) I get

2015-11-11 09:14:05.520 clion[52477:1816658] Value of CLION_JDK: (null)
2015-11-11 09:14:05.524 clion[52477:1816674] fullFileName is: /Applications/CLion.app/Contents/bin/clion.vmoptions
2015-11-11 09:14:05.524 clion[52477:1816674] fullFileName exists: /Applications/CLion.app/Contents/bin/clion.vmoptions
2015-11-11 09:14:05.524 clion[52477:1816674] Value of CLION_VM_OPTIONS is (null)
2015-11-11 09:14:05.524 clion[52477:1816674] Processing VMOptions file at /Applications/CLion.app/Contents/bin/clion.vmoptions
2015-11-11 09:14:05.525 clion[52477:1816674] Done
/Applications/CLion.app/Contents/bin/idea.properties: 'java.endorsed.dirs' already defined

Too Many Instances: Only one instance of CLion can be run at a time.


and in the running CLion there is an error message complaining that /Applications/CLion.app/Contents/bin/./inspect does not exist.

Thanks,
Philippe

0

Philippe,

Could you please specify which command did you use?

0
Avatar
Permanently deleted user

I tried:

/Applications/CLion.app/Contents/bin/inspect.sh /opt/build/root_builds/rootcling.debug ~/Library/Preferences/clion11/inspection/Default.xml /opt/build/root_builds/rootcling.debug/src/core/base/src/TROOT.cxx 


where /opt/build/root_builds/rootcling.debug is the location of the (already opened) project and /opt/build/root_builds/rootcling.debug/src/core/base/src/TROOT.cxx the location of the file.

Thanks,
Philippe.

0

Hi Philippe.

Sorry for the delay!
To open file for editing please type the following in the command line:

<CLion> <path1> --line<number> <path2>

where:
  • <CLion>
    is the platform-specific product launcher
  • <path1>
    is the path to the project that contains the desired file
  • <number>
    is the number of the line, where the caret should rest
  • <path2>
    is the path to the file to be opened


An example for OS X:
/Applications/CLion.app/Contents/MacOS/clion ~/CLionProjects/untitled45 --line 1 ~/CLionProjects/untitled45/sample.txt


Does that help?
0
Avatar
Permanently deleted user

Hi Anna,

This is indeed working.  Thanks,

I see the --line option, where can I find the complete list of supported command line options?

Thanks,
Philippe.

0
Avatar
Permanently deleted user

Is there any way to automatically use the current project if only one instance of clion is open?

 

0

Please sign in to leave a comment.