Reputation: 10623
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?
Upvotes: 39
Views: 36436
Reputation: 849
Open settings, Tools->Terminal->Shell path, just set /bin/bash
。Reopen IDE, open terminal to test it. If it doesn't work, run exit
and then reopen a new terminal, maybe it will take effects.
Upvotes: 1
Reputation: 2604
For me at least, the only thing that works was to put this in the Shell path
variable inside of Tools > Terminal :
/bin/bash --rcfile ~/.bashrc
Upvotes: 1
Reputation: 191
Had the same issue with IntelliJ.
Solved this by setting the value /bin/bash --login
in setting->Tools->Terminal->Shell path
.
/bin/bash --login
forces the bash to read the ~/.bash_profile
.
Upvotes: 19
Reputation: 16499
.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!)
Upvotes: 55
Reputation: 677
On Mac OSX Catalina, "/bin/bash"
and ~/.zprofile
worked for me:
Apple has changed the default shell to zsh.
Therefore you have to rename your configuration files. .bashrc
is now .zshrc
and .bash_profile
is now .zprofile
.
Upvotes: 9
Reputation: 29
Create a bash script with the content;
echo "source ~/.bash_profile" >> .profile
Then in Intellij go to preferences/tools/Startup Tasks;
create a run configuration that runs your bash script and you're good to go.
Upvotes: 0
Reputation: 3797
If you have recently moved to zsh from bash then go to ~/.zshrc
file and update $PATH variable there:
Default value in .zshrc
:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
Change to same PATH variable set in .bashrc
and uncomment it
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:<my-bash-paths>:$PATH
Upvotes: 1
Reputation: 57287
I had this problem because the default shell had been changed to zsh
.
I echoed the shell name with echo $SHELL
to see this (thanks How to get default shell).
Then I changed it back to /bin/bash
with this command: chsh -s /bin/bash
(thanks https://apple.stackexchange.com/a/100476/176809).
Upvotes: 0
Reputation: 8899
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
:)
Upvotes: 10
Reputation: 17114
None of these answers worked for me. What did work is
sudo nano /etc/environment
...then manually adding my export
and alias
commands here to make them system wide.
But be careful, do NOT mess up the PATH or you'll have trouble logging back in to your desktop environment, or many other issues.
Upvotes: 0
Reputation: 307
My settings are in ~/.bash_profile . I solved it using:
echo "source ~/.bash_profile" >> .profile
Upvotes: 3
Reputation: 22186
I noticed that .bashrc
isn't sourced only when I first install IntelliJ and run it directly via the idea.sh
script in bin/
.
Once I create the desktop entry via Tools -> Create Desktop Entry...
and start it from the Ubuntu dash, .bashrc
is sourced properly.
Upvotes: 1
Reputation: 14385
Because >
operator doesn't pass the sudo permissions to the write process.
I did this :
echo ". ~/.bashrc" | sudo tee /etc/bash.bashrc
Upvotes: 1
Reputation: 15461
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
Upvotes: 13