bash .bashrc 不是来自 Intellij IDEA 的终端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36592226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.bashrc not sourced on Intellij IDEA's terminal
提问by Alexander Suraphel
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?
我.bashrc
在我的 Intellij IDEA 终端上定义了一些别名。为什么.bashrc
没有来源?
采纳答案by Ognjen
sudo echo ". ~/.bashrc" >> /etc/bash.bashrc
回答by Kyle Strand
.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.
.bashrc
仅在 Bash 以“交互”模式运行时加载。出于某种原因,IntilliJ 默认以非交互模式运行 Bash,但这很容易改变。打开 IntelliJ 设置窗口,然后打开“工具 -> 终端”,并添加-i
到 shell 路径。
(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!)
(注意,在这个截图中,我也更改了默认shell,因为我在Mac上,这使得更新变得困难/bin/bash
。除非您安装了不同版本的Bash,否则不要盲目复制此更改!)
回答by SLePort
In your home directory, add theses lines to .profile
(create the file if it does not exist), in order to source .bashrc
:
在您的主目录中,将这些行添加到.profile
(如果文件不存在则创建该文件),以便获取.bashrc
:
if [ "$SHELL" = "/bin/bash" ]; then
. ~/.bashrc
fi
回答by Saravanabalagi Ramachandran
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
:)
工作。我们利用交互式 shell 加载的 hack .bashrc
:)
回答by masoud soroush
On Mac OSX Catalina, "/bin/bash"
and ~/.zprofile
worked for me:
在Mac OSX卡塔利娜,"/bin/bash"
并~/.zprofile
对我来说有效:
Update:
更新:
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
.
Apple 已将默认 shell 更改为zsh.
因此您必须重命名您的配置文件。.bashrc
现在是.zshrc
和.bash_profile
现在.zprofile
。
回答by Dimitri Kopriwa
Because >
operator doesn't pass the sudo permissions to the write process.
因为>
操作员没有将 sudo 权限传递给写入过程。
I did this :
我这样做了:
echo ". ~/.bashrc" | sudo tee /etc/bash.bashrc
回答by Zoltán
I noticed that .bashrc
isn't sourced only when I first install IntelliJ and run it directly via the idea.sh
script in bin/
.
我注意到,.bashrc
并非仅来源于当我第一次安装的IntelliJ和直接通过运行idea.sh
脚本bin/
。
Once I create the desktop entry via Tools -> Create Desktop Entry...
and start it from the Ubuntu dash, .bashrc
is sourced properly.
一旦我通过创建桌面条目Tools -> Create Desktop Entry...
并从 Ubuntu dash 启动它,.bashrc
它的来源就正确了。
回答by Eidan Spiegel
My settings are in ~/.bash_profile . I solved it using:
我的设置在 ~/.bash_profile 中。我使用以下方法解决了它:
echo "source ~/.bash_profile" >> .profile
回答by TetraDev
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.
...然后在此处手动添加 myexport
和alias
命令以使它们在系统范围内使用。
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.
但要小心,不要弄乱 PATH,否则您将无法重新登录到桌面环境,或出现许多其他问题。
回答by Ben
I had this problem because the default shell had been changed to zsh
.
我遇到这个问题是因为默认 shell 已更改为zsh
.
I echoed the shell name with echo $SHELL
to see this (thanks How to get default shell).
我回显了 shell 名称echo $SHELL
以查看此内容(感谢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).
然后我/bin/bash
用这个命令把它改回:(chsh -s /bin/bash
感谢https://apple.stackexchange.com/a/100476/176809)。