When I use the binary file to open a text file in PyCharm with...
$ /snap/bin/pycharm-community my_text_file
... it opens PyCharm in LightEdit mode.
Often, I'll be working in a PyCharm project and I want to create/open a file. To this end, I'd like to go to the terminal in PyCharm, run something like the command above and have it open the file in my current project.
I know I can use the graphical user interface to accomplish this. I'd rather do it from the command line, hence the following question.
How do I open PyCharm in my current project from the command line?
(...) open a text file in PyCharm with. . .
$ /snap/bin/pycharm-community my_text_file
...it opens PyCharm in LightEdit mode.
That happens if you are opening an individual file. If the argument is a directory containing an .idea
folder PyCharm will open it like a regular project.
To this end, I'd like to go to the terminal in PyCharm, run something like the command above and have it open the file in my current project.
If you run the same command from the terminal inside or outside PyCharm while the IDE is already running the file will be opened in the editor and the IDE will not be in LightEdit mode.
However, if the file is outside a project's content or sources roots, tests, etc.. it will be opened as a file that's not included in the project -notice the visual queue of the yellow background in the editor tab- and correctly so because it is not part of the project. If the file is already inside one of the folders that are part of the project it will be opened as such.
A final note:
If you want to open a file from the command line that is not part of a currently open project and simultaneously include it in a project; that is not possible using only the command line because PyCharm does not have such a command available. (See the command-line arguments of the IDE.)
This functionality is not as direct as it may seem, because you can have several windows open in PyCharm, each window with several open projects, and each project can have several sources roots. (So to which directory, in which project, in which window, should the IDE add the file?)
If you know exactly where you want to place the file, then you can easily write a shell script that invokes PyCharm, moves the file to where you want, or updates PyCharm's sources and content roots by editing the project setting files.