centos ssh终端下高亮显示git分支名
2024-10-19 04:32:08
#set git branch
green=$'\e[1;32m'
magenta=$'\e[1;35m'
normal_colours=$'\e[m' function 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=' (unknown)'
fi
return
fi
dir="../$dir"
done
git_branch=''
} PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND"
PS1="\[$green\]\u@\h:\w\[$magenta\]\$git_branch\[$green\]\\[$normal_colours\] "
将上面这段,追加 /etc/profile 或 ~/.bash_profie 或 ~/.bashrc 任何一个的最后,然后source /etc/profile (或source ~/.bash_profile 或 source ~/.bashrc),让其生效即可。
最终效果:
最新文章
- java的remote shell
- Python 去剑式
- 判断是否含有中文,包含返回true,不包含返回false
- mvc5引用ExtJS6
- cocoapods 终极方案
- ibatis报错
- Top 100 English Verbs
- 定制化Azure站点Java运行环境(4)
- Java图形化界面设计——布局管理器之null布局(空布局)
- untiy 播放视频
- iOS8的屏幕旋转的问题
- setChecked方法触发onCheckedChanged监听器问题
- Java GC算法 垃圾收集器
- popupwindow那些坑
- vue 内联样式style中的background
- java某些基础知识点整理
- spark-MLlib之线性回归
- linux命令--xargs的使用
- EF 传递的主键值的数量必须与实体上定义的主键值的数量匹配 原因
- C语言实例:数组与字符串
热门文章
- Python 入门基础2 --基本数据类型、运算符
- Contrastive Loss (对比损失)
- Linux输出重定向>;和>;>;的区别是什么
- SQLServer xp_instance_regread returned error 5,Access is denied(配置最小权限)
- hdu 4348 To the moon (主席树)
- (windows下)安装mysql
- ajax调用WebService 不能跨域
- win10编译caffe跑faster-rcnn(cuda7.5)
- Atom组件
- Linux下jdk、Tomcat、MySQL的安装