Shell 显示所在项目当前git分支及状态
来源:互联网 发布:黑暗之魂剧情分析知乎 编辑:程序博客网 时间:2024/06/01 07:52
修改文件,添加如下vim .bashrc
function git_branch { ref=$(git symbolic-ref HEAD 2> /dev/null) || return; echo "("${ref#refs/heads/}") ";}function parse_git_dirty { local git_status=$(git status 2> /dev/null | tail -n1) || $(git status 2> /dev/null | head -n 2 | tail -n1); if [[ "$git_status" != "" ]]; then local git_now; # 标示 if [[ "$git_status" =~ nothing\ to\ commit || "$git_status" =~ Your\ branch\ is\ up\-to\-date\ with ]]; then git_now="="; elif [[ "$git_status" =~ Changes\ not\ staged || "$git_status" =~ no\ changes\ added ]]; then git_now='~'; elif [[ "$git_status" =~ Changes\ to\ be\ committed ]]; then #Changes to be committed git_now='*'; elif [[ "$git_status" =~ Untracked\ files ]]; then git_now="+"; elif [[ "$git_status" =~ Your\ branch\ is\ ahead ]]; then git_now="#"; fi echo "${git_now}"; fi}PS1="[\[\e[1;35m\]\u\[\e[1;32m\]\w\[\e[0m\]] \[\e[0m\]\[\e[1;36m\]\$(git_branch)\[\033[0;31m\]\$(parse_git_dirty)\[\033[0m\]]\$";
阅读全文
0 0
- Shell 显示所在项目当前git分支及状态
- linux 显示所在项目当前分支及git状态
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 在Mac、Linux 终端显示 Git 当前所在分支
- 让 shell 显示当前 git 的分支名称
- Terminal git 显示当前分支
- eclipse项目显示git分支
- linux下显示git当前分支
- 让terminal显示git所在的当前分支名
- Ubuntu下显示git分支的状态
- centos下git分支状态显示配置
- 【git】git保存当前状态切换分支的方法
- shell脚本----在 Shell 提示符中显示 Git 分支名称
- 解决git detached 状态 恢复分支名字的显示
- kotlin for android 集成&&简单使用
- SQL中char、varchar、text区别
- 求LCA的几种方法
- Android动态加载Jar包并实现Native方法
- c语言常见的几种指针用法
- Shell 显示所在项目当前git分支及状态
- JavaScript 生成器函数function* () {}
- C语言sscanf函数的总结
- JZOJ 3927. 【NOIP2014模拟11.6】可见点数
- 用PDF编辑软件简PDF文档进行上下标简不简单?
- 环境变量的配置--java开发环境
- 【Android资源管理和打包】深入理解Gradle
- 阿里云四轮技术面回顾(四面跪归)
- MTK Android Driver :battery