ubuntu显示当前分之
home
目录cd ~
.bashrc
文件vi .bashrc
function git_branch {
branch="`git branch 2>/dev/null | grep "^\*" | sed -e "s/^\*\ //"`"
if [ "${branch}" != "" ];then
if [ "${branch}" = "(no branch)" ];then
branch="(`git rev-parse --short HEAD`...)"
fi
echo " ($branch)"
fi
}
export PS1='\u@\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ '
source ./.bashrc
Mac 下面启动的 shell 是 login shell,所以加载的配置文件是
.bash_profile
,不会加载.bashrc
。如果你是 Mac 用户的话,需要再执行下面的命令,这样每次开机后才会自动生效:
echo "[ -r ~/.bashrc ] && source ~/.bashrc" >> .bash_profile