linux 命令行终端显示git 当前所在分支
2018-03-10 16:27
726 查看
在 .bashrc 里面添加
#show the current git branch find_git_branch () { local dir=. head until [ "$dir" -ef / ]; do if [ -f "$dir/.git/HEAD" ]; then head=$(< "$dir/.git/HEAD") if [[ $head = ref:\ refs/heads/* ]]; then git_branch="(*${head#*/*/})" elif [[ $head != '' ]]; then git_branch="(*(detached))" else git_branch="(*(unknow))" fi return fi dir="../$dir" done git_branch='' } PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND" PS1="\u@\h:\w\[\033[0;32m\]\$git_branch\[\033[0m\] \$ "
相关文章推荐
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- linux 显示所在项目当前分支及git状态
- git在MAC,Linux的terminator(命令行)下自动显示当前分支
- Mac系统的终端显示git当前分支
- 如何在linux命令行中显示git分支
- Linux 命令行 自动显示 项目当前分支
- 让terminal显示git所在的当前分支名
- Mac系统的终端显示git当前分支
- 终端shell显示当前git分支_修订版
- Shell 显示所在项目当前git分支及状态
- Linux下命令行显示当前全路径方法
- linux终端命令行缩短显示路径
- Linux终端只显示当前路径
- centos ssh终端下高亮显示git分支名