Ubuntu14.04 64位上配置终端显示git分支名称
生活随笔
收集整理的這篇文章主要介紹了
Ubuntu14.04 64位上配置终端显示git分支名称
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
????之前在Ubuntu14.04上在終端上顯示git分支名稱基本上都使用oh-my-zsh,可以參考?https://blog.csdn.net/fengbingchun/article/details/77803322? ,由于限制了權限,使得不能安裝oh-my-zsh,顯示錯誤如下:
????? ? 在?https://github.com/robbyrussell/oh-my-zsh/issues/4789?中給出了對上述錯誤的解釋。
????? ? 不能使用oh-my-zsh,在網上?https://www.jianshu.com/p/82783f76a868?中介紹了一種方法,即在~/.bashrc文件末尾加入下面一段腳本并保存:??
function git-branch-name {git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
}
function git-branch-prompt {local branch=`git-branch-name`if [ $branch ]; then printf " [%s]" $branch; fi
}
PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "
????? ? 使修改生效,執行: $ source ~/.bashrc
????? ? 在有git的工作目錄下,即會顯示git分支名稱,如下:
總結
以上是生活随笔為你收集整理的Ubuntu14.04 64位上配置终端显示git分支名称的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu 14.04 64位上配置J
- 下一篇: LLVM简介