Linux显示所在Git分支
1.进入你的home
目录
cd ~
2.编辑.bashrc
文件
vi .bashrc
3. 将下面的代码加入到文件的最后处
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=‘\\h \[\033[01;36m\]\W\[\033[01;32m\]$(git_branch)\[\033[00m\] \$ ‘
4.保存退出
5.执行加载命令
source ./.bashrc
相关推荐
skyplay0 2020-11-17
JumpingYeah 2020-02-02
Javawucao 2020-01-31
乾坤一碼農 2020-01-08
就是那个胖子 2020-01-07
JumpingYeah 2020-01-07
huangchunxia 2019-12-07
chaocc0xs 2019-11-19
JumpingYeah 2019-10-21
MyselfWqx 2016-12-31
tianyafengxin 2019-07-31
webhwg 2012-08-15
okokyu 2011-12-08
huangchunxia 2011-11-09