zoukankan      html  css  js  c++  java
  • 终端shell显示当前git分支_修订版

    终端shell显示当前git分支

                                                              

    修改前:

     

     

    修改后:

     

     

    项目当前的分支比较多,所以修改时,不太注意的话,分支就容易弄错,基于以上原因,从网上学习找到了一个配置,在当前的命令终端显示当前修改的项目分支。

     

    仅供参考。

     

    Ubuntu 系统,修改一下文件 (IP地址,按照自己的服务器配置)

    \192.168.3.30 elease330.bashrc

     

    .bashrc文件最后 增加获取git当前分支的方法

     

    function git_branch {

        ref=$(git symbolic-ref HEAD 2> /dev/null) || return;

        echo "("${ref#refs/heads/}") ";

    }

     

    修改下面内容

     

    if [ "$color_prompt" = yes ]; then

    PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$ '

    else

    修改后

    PS1="${debian_chroot:+($debian_chroot)}[e[m]u@h[33[00m]:[e[m]w[33[0m] [33[0m][33[1;36m]$(git_branch)[33[0;33m]$ "

    修改前

    #PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '

    fi

  • 相关阅读:
    android作业10.21
    安卓10.7作业
    安卓9.30
    9.23作业
    9.17安卓作业
    6.12作业
    5.29作业
    5.28上机作业
    leetcode 219
    策略模式
  • 原文地址:https://www.cnblogs.com/kevincode/p/3823851.html
Copyright © 2011-2022 走看看