【发布时间】:2017-06-20 21:20:32
【问题描述】:
我正在开发一个 bash 脚本,它将当前分支添加到我的终端提示符中,并在我 cd 进入作为终端中的 git 存储库的文件夹时显示有关此文件夹中最近提交的信息
问题是每当我在该存储库文件夹中使用git checkout 切换分支时,提示不会更新当前分支
这是我的 bash 代码,位于我的 .bashrc 文件中
cd() {
builtin cd "$@"
local status=$?
[ $status -eq 0 ] && PS1="[\e[0;32m${debian_chroot:+($debian_chroot)}\w\e[m]\e[0;35m$(parse_git_branch)\e[m \n$ "
if [ -d .git ]; then
echo -e "\nMost Recent Commit"
git show --summary;
fi
return $status
}
【问题讨论】: