diff --git a/bash_tools/theme_bash.sh b/bash_tools/theme_bash.sh index 0ca4013..01456e8 100644 --- a/bash_tools/theme_bash.sh +++ b/bash_tools/theme_bash.sh @@ -3,6 +3,20 @@ export GIT_PS1_SHOWDIRTYSTATE=1 if [[ $(type -t foo) != function ]]; then __git_ps1(){ + + local branch=`git branch 2>/dev/null | grep '*' | sed 's/* \(.*\)/\1/'` + + if [ $? ]; then + status=`git status 2>/dev/null` + local stage_info="not staged for commit" + local commit_info="Changes to be committed" + + local stage_sign='' + local commit_sign='' + [[ "$status" == *"$stage_info"* ]] && stage_sign=" *" + [[ "$status" == *"$commit_info"* ]] && commit_sign=" +" + echo "(${branch}${stage_sign}${commit_sign})" + fi } fi export PS1=' \[\e[0;32m\]\w\[\e[01;31m\]$(__git_ps1 "(%s)")\[\e[00m\]$ ' diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..2e5a14d --- /dev/null +++ b/test.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +a="asfsdfs +dfdfd +fdfff +ggg" + +grep ggg $a