Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.bashrc not sourced on Intellij IDEA's terminal

Tags:

I have some aliased defined on my .bashrc that I'd like to use on my Intellij IDEA's terminal. Why is .bashrc not sourced?

like image 498
Alexander Suraphel Avatar asked Apr 13 '16 08:04

Alexander Suraphel


People also ask

How do I enable terminal in Intellij?

Open the Terminal tool windowFrom the main menu, select View | Tool Windows | Terminal or press Alt+F12 .

Is Bashrc sourced?

bashrc file is a script, and by sourcing it, you execute the commands placed in that file. The commands define aliases in your case, but there can be virtually any commands placed in that file. you could also use exec bash to replace the current bash process with a new.

Is Bashrc the same as bash_profile?

bash_profile is read and executed when Bash is invoked as an interactive login shell, while . bashrc is executed for an interactive non-login shell. Use . bash_profile to run commands that should run only once, such as customizing the $PATH environment variable .


2 Answers

.bashrc is only loaded when Bash is running in "interactive" mode. For some reason, IntelliJ 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

like image 84
Kyle Strand Avatar answered Oct 01 '22 03:10

Kyle Strand


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    
like image 30
SLePort Avatar answered Oct 01 '22 05:10

SLePort