简体   繁体   中英

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

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  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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