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

本小妞迷上赌 提交于 2019-12-23 03:58:15

问题


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. Is there a reason why they're not working like they should be?

Here's the inside of my .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

[[ -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!


回答1:


In OSX, all sessions are login sessions and will not source $HOME/.bashrc, they will source $HOME/.profile or $HOME/.bash_profile. So put the following in your .bash_profile

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


来源:https://stackoverflow.com/questions/44658135/osx-terminal-not-recognizing-bashrc-and-bash-profile-on-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!