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?
Open the Terminal tool windowFrom the main menu, select View | Tool Windows | Terminal or press Alt+F12 .
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.
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 .
.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!)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With