.bashrc not sourced on Intellij IDEA's terminal

.bashrc is only loaded when Bash is running in "interactive" mode. For some reason, IntilliJ defaults to running Bash in non-interactive mode, but this is easy to change. Open the IntelliJ settings window, then open "Tools -> Terminal", and add -i to the shell path.

(Note that in this screenshot, I have also changed the default shell, because I'm on a Mac, which makes it difficult to update /bin/bash. Unless you have installed a different version of Bash, do not blindly copy this change!)

enter image description here


In your home directory, add theses lines to .profile (create the file if it does not exist), in order to source .bashrc:

if [ "$SHELL" = "/bin/bash" ]; then
    . ~/.bashrc
fi   

For me, changing the line

Exec="/opt/idea-IU-183.4284.148/bin/idea.sh" %f

to

Exec=bash -ic "/opt/idea-IU-183.4284.148/bin/idea.sh" %f 

worked. We exploit the hack that the interactive shell loads .bashrc :)