我想让我的命令提示符不显示我的用户名,但要显示我目前在哪个git分支。换句话说,这是我想要的:
[master]$ ls README INSTAL whatever.py [master]$ git checkout other-branch [other-branch]$
有没有办法让提示自定义这么多?
PS1='[`git rev-parse --abbrev-ref HEAD 2> /dev/null`]$ '
看到这里使用特定的git命令的帮助。 对我来说,关键是要意识到我可以将任意命令插入PS1环境variables:)