OSX终端在启动时无法识别〜

OSX终端在启动时无法识别〜

本文介绍了OSX终端在启动时无法识别〜/.bashrc和〜/.bash_profile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OSX识别.bashrc和.bashprofile的唯一方法是,如果我在终端的首选项中指定了引导时要定位的文件.他们为什么没有按照应有的方式工作?

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?

这是我的.bashrc的内部

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\$ "

.bash_profile内

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!

推荐答案

在OSX中,所有会话都是登录会话,并且不会作为$HOME/.bashrc的源,而是作为$HOME/.profile$HOME/.bash_profile的源.因此,将以下内容放入您的.bash_profile

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

这篇关于OSX终端在启动时无法识别〜/.bashrc和〜/.bash_profile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 13:08