终端颜色不显示

终端颜色不显示

因此,如果存在 git 分支,则在我的 git 分支中显示以下内容~/.bashrc(有效)。当我保存文件并运行 时source ~/.bashrc,颜色不会显示。我只有一个黑底白字的终端,但它确实显示了当前分支。这是否仅在我 ssh 进入服务器时才有效?从我读过的内容来看,每个人都在 ssh 进入服务器。如果是这样,我该如何让它在本地工作?

force_color_prompt=yes

parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
unset color_prompt force_color_prompt

相关内容