bash macOS Catalina 10.15(beta) - 为什么 ~/.bash_profile 不是由我的 shell 提供的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/56784894/
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
macOS Catalina 10.15(beta) - Why is ~/.bash_profile not sourced by my shell?
提问by Reza Dehnavi
I want to set the environment variable I added below the line to ~/.bash_profile
and ~/.profile
but it didn't work.
我想设置我在该行下方添加的环境变量~/.bash_profile
,~/.profile
但它不起作用。
export JBOSS_HOME=/Users/{USERNAME}/Desktop/jboss7
Afterward, exit the terminal and open it again when executing echo $JBOSS_HOME
I get nothing.
回答by fdg13gustav
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 Rostyslav Druzhchenko
If you for some reason (as me) don't want to rename/move your ~/.bash_profile
file you can do the next things:
如果您出于某种原因(如我)不想重命名/移动您的~/.bash_profile
文件,您可以执行以下操作:
- Create a new file
~/.zprofile
- Type there
source ~/.bash_profile
- Save and close
- Run a new terminal session
- 创建一个新文件
~/.zprofile
- 在那里输入
source ~/.bash_profile
- 保存并关闭
- 运行一个新的终端会话
回答by ExoWanderer
I created a new file called
我创建了一个名为的新文件
/usr/local/bin/mybash
/usr/local/bin/mybash
which contains a wrapper script:
其中包含一个包装脚本:
/usr/local/bin/bash --init-file $HOME/.bashrc
/usr/local/bin/bash --init-file $HOME/.bashrc
I installed this local/bin/bash from HomeBrew.
我从HomeBrew安装了这个 local/bin/bash 。
Full Sequence of Events
完整的事件序列
brew install bash
echo "/usr/local/bin/bash --init-file $HOME/.bashrc" > /usr/local/bin/mybash
chmod +x /usr/local/bin/mybash
Then I opened the settings for terminal.app
[cmd-comma]. Under the General
Tab, select the radio button for Command (complete path)
然后我打开了terminal.app
[cmd-comma]的设置。在General
选项卡下,选择单选按钮Command (complete path)
In the text box change the text from /bin/zsh/
to /usr/local/bin/bash
.
在文本框中将文本从 更改/bin/zsh/
为/usr/local/bin/bash
。
回答by vikas kumar
changing the bash profile to zsh profile works and source it as well to see in action.
将 bash 配置文件更改为 zsh 配置文件可以工作并获取它以查看操作。
vikas@Vikas-Kumar ~ % mv .bash_profile .zsh_profile
vikas@Vikas-Kumar ~ % source .zsh_profile
回答by Gilberto
You can create a simbolic link and keep your .bash_profile file with this:
您可以创建一个符号链接并使用以下内容保留您的 .bash_profile 文件:
ln -s .bash_profile .zsh_profile
source .zsh_profile
Any changes in .bash_profile will be reflected in .zsh_profile
.bash_profile 中的任何更改都将反映在 .zsh_profile 中
回答by Maggie
cp zprofile ~/.zprofile
Add to .zprofile
:
添加到.zprofile
:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
eg. by >vi .zprofile
例如。经过>vi .zprofile
Done
完毕