linux下.bashrc为什么每次打开终端都要source一下才有效?

2025-04-26 08:37:48
推荐回答(1个)
回答1:

在当前用户目录,增加一个.profile文件,增加以下内容

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi