简体   繁体   English

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

[英]OSX Terminal not recognizing ~/.bashrc and ~/.bash_profile on startup

The only way my .bashrc and .bashprofile are recognized by OSX is if I specify in my terminal's preferences for the file to be targeted upon boot. OSX可以识别.bashrc和.bashprofile的唯一方法是,如果我在终端的首选项中指定了引导时针对的文件。 Is there a reason why they're not working like they should be? 他们为什么没有按照应有的方式工作?

Here's the inside of my .bashrc 这是我的.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\$ "

Inside of .bash_profile 在.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 ..'

Any help would be appreciated! 任何帮助,将不胜感激! Thanks! 谢谢!

In OSX, all sessions are login sessions and will not source $HOME/.bashrc , they will source $HOME/.profile or $HOME/.bash_profile . 在OSX中,所有会话都是登录会话,并且不会源$HOME/.bashrc ,而将源$HOME/.profile$HOME/.bash_profile So put the following in your .bash_profile 因此,将以下内容放入您的.bash_profile

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM