Launch Pycharm from command line (terminal)
I want to try out PyCharm for sage mathematics development. Normally I run eclipse to do sage development, but now I want to try it with PyCharm.
To launch eclipse with sage environment variables, in command line I normally do the following:
sage -sh
cd /path/to/eclipse
./eclipse
The first line loads the sage environment variables, the remainder launches eclipse. How can I do the same thing for pyCharm? (note I am using a Mac and Ubuntu for sage development; the commands above are agnostic to both OSes)
- Link 1 is close to the solution I am looking for, however I cannot find a pyCharm.sh anywhere.
- Link 2: Jetbrains does not give clear instructions either.
Edit (April 2020): It seems that launcher script creation is now managed in Toolbox App settings. See the Toolbox App announcement for more details.
--
- Open Application Pycharm
- Find tools in menu bar
- Click
Create Command-line Launcher
- Checking the launcher executable file which has been created in
/usr/local/bin/charm
- Open project or file just type
$ charm YOUR_FOLDER_OR_FILE
Maybe this is what you need.
Inside the IDE, you can click in:
Tools/Create Command-line Launcher...
You're right that the JetBrains help page isn't very clear. On OS X, you'll want to use the launcher at:
/Applications/PyCharm.app/Contents/MacOS/pycharm
Or, for community edition:
/Applications/PyCharm\ CE.app/Contents/MacOS/pycharm
Unfortunately, adding a symlink to this binary wouldn't work for me (the launcher would crash). Setting an alias worked, though. Add this in your .bash_profile
(or whatever shell you use):
alias pycharm="/Applications/PyCharm CE.app/Contents/MacOS/pycharm"
Then, you can run commands with simply pycharm
.
With this you can do things like open a project:
pycharm ~/repos/my-project
Or open a specific line of a file in a project:
pycharm ~/repos/my-project --line 42 ~/repos/my-project/script.py
Or view the diff of two files (they don't need to be part of a project):
pycharm ~/some_file.txt ~/Downloads/some_other_file.txt
Note that I needed to pass absolute paths to those files or PyCharm couldn't find them..