For the past few months I’ve been writing my code in the JetBrains PyCharm IDE. While there are things I still prefer about Sublime Text, the overall feature set in PyCharm has won me over.
Something that was killing me, though, was the inability to open files and directories from the command line. Thanks to stackoverflow, I found a workaround. Here’s how to do it:
Edit your .bash_profile
to include the following:
# Adds PyCharm to the command line.
alias pycharm="/Applications/PyCharm.app/Contents/MacOS/pycharm"
From the command line you can now use the command pycharm
to open a file in PyCharm. The only caveat is that you need to provide the full path to the file or directory you want to open. The easiest way to do this is to use pwd
. If I’m in a directory that has a file, hello.py
, that I want to open, I’d type the following:
> pycharm `pwd`/hello.py
Or I could open a folder in PyCharm
> pycharm `pwd`/hello