bash - OSX 终端在启动时无法识别 ~/.bashrc 和 ~/.bash_profile

标签 bash macos terminal

我的 .bashrc 和 .bashprofile 被 OSX 识别的唯一方法是,如果我在终端的首选项中指定启动时要定位的文件。他们没有按应有的方式工作是否有原因?

这是我的 .bashrc 的内部

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # 
Load RVM into a shell session *as a function*
#Add RVM to PATH for scripting. Make sure this is the last PATH 
variable change.
export PATH="$PATH:$HOME/.rvm/bin"
smiley () { echo -e ":\\$(($??50:51))"; }
export PS1="\h\$(smiley) \e[30;1m\w\e[0m\n\$ "

.bash_profile 内部

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # 
Load RVM into a shell session *as a function*
# Add RVM to PATH for scripting. Make sure this is the last PATH n . 
variable change.
export PATH="$PATH:$HOME/.rvm/bin"
alias b='cd ..'

任何帮助将不胜感激!谢谢!

最佳答案

在 OSX 中,所有 session 都是登录 session ,不会获取 $HOME/.bashrc,它们会获取 $HOME/.profile$HOME/.bash_profile。所以将以下内容放入您的 .bash_profile

if [ -f ~/.bashrc ]; then                                                            
 source ~/.bashrc                                                                
fi  

关于bash - OSX 终端在启动时无法识别 ~/.bashrc 和 ~/.bash_profile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44658135/

相关文章:

bash - 在 bash complete 中指定两个文件扩展名

macos - 如何修复终端在 OS X Lion 上不加载 ~/.bashrc

linux - 如何从终端启动命令以使终端不是父终端?

c - 在终端上键入`node`时运行的代码

linux - 如何从 bash 脚本确定 gcc 的配置?

c++ - Xcode 6 : Create pure C++ OpenGL application bundle (. 应用程序)不使用 "Cocoa Application"模板

python - 使用参数启动 python shell

c - session 中的现有进程将如何了解和获取 session 领导者刚刚获取的控制终端?

linux - 通过 Cron 的 Bash 脚本结果不同

ios - 如何在 CoreMidi 轨道中播放特定 channel ?