我在.bashrc
文件中定义了一些别名,希望在Intellij IDEA的终端中使用。为什么.bashrc
文件没有被执行?
我在.bashrc
文件中定义了一些别名,希望在Intellij IDEA的终端中使用。为什么.bashrc
文件没有被执行?
bash -i
(交互式),它将在打开新选项卡时运行~/.bashrc
; 如果它调用bash
(非交互式),则会运行~/.bash_profile
。在macOS Catalina上通过WebStorm 2020.3.3进行了验证。 - Ricardo--login -i
也应该可以工作,但是 login
可能不是你想要的。虽然我不知道为什么 -i
单独不能解决你的问题。 - Kyle Strand--login
或-l
单独使用(不带-i
)可以满足我需要的目的,即加载.bash_profile
。这个SO问题是关于.bashrc
的,所以我现在意识到这是不相干的。无论如何,谢谢你,随意忽略! - Barney我在IntelliJ中也遇到了同样的问题。将/bin/bash --login
这个值设置到setting->Tools->Terminal->Shell path
中,问题解决了。
/bin/bash --login
会强制bash读取~/.bash_profile
文件。
在您的主目录中,将这些行添加到.profile
文件中(如果不存在该文件,则创建它),以便源化.bashrc
:
if [ "$SHELL" = "/bin/bash" ]; then
. ~/.bashrc
fi
/bin/bash
。我为什么要改变它呢? - Alexander Suraphel~/.profile
文件,它大概长这样:# 如果正在运行bash
if [ -n "$BASH_VERSION" ]; then
# 如果存在,就包含.bashrc
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi 我认为这应该足够了,对吧? - Alexander Suraphel对我来说,改变这行
Exec="/opt/idea-IU-183.4284.148/bin/idea.sh" %f
到
Exec=bash -ic "/opt/idea-IU-183.4284.148/bin/idea.sh" %f
工作了。我们利用交互式 shell 载入 .bashrc
的技巧 :)
nvm
的 node.js,并且为了让 node 在 PATH
中可用,.bashrc
应该在 IDE 之前执行。我改进了这个解决方案:bash -ic "exec /path/to/webstorm.sh %f"
,也就是处理 %f
并使用 exec
替换 bash。 - Konstantin Pelepelin我的设置在~/.bash_profile文件中。我通过以下方式解决了这个问题:
echo "source ~/.bash_profile" >> .profile
sudo echo ". ~/.bashrc" >> /etc/bash.bashrc
bin/
中的idea.sh
脚本运行时,.bashrc
才不会被调用。
一旦我通过工具->创建桌面条目...
创建桌面条目并从Ubuntu dash启动它,.bashrc
会被正确调用。
echo ". ~/.bashrc" | sudo tee /etc/bash.bashrc
~/.zshrc
文件并在其中更新$PATH变量:
.zshrc
中的默认值:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:<my-bash-paths>:$PATH