summaryrefslogtreecommitdiff
path: root/01_Functions.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2007-09-25 16:24:11 +0200
committerHugues Hiegel <hugues@hiegel.fr>2008-03-07 14:15:18 +0100
commitaba1f798c86b07247f2b725fdc5c0ee9e2a198be (patch)
tree65c4a327d5d5795297083a2e134a2d2f8ce5877b /01_Functions.zsh
parent68f04afba2bfd7570aa9a34ef01b4bc87b0d1fb0 (diff)
on-demand git-status (with M-g, and M-G to clear)
Diffstat (limited to '01_Functions.zsh')
-rw-r--r--01_Functions.zsh29
1 files changed, 29 insertions, 0 deletions
diff --git a/01_Functions.zsh b/01_Functions.zsh
index 2d2407a..810a04e 100644
--- a/01_Functions.zsh
+++ b/01_Functions.zsh
@@ -14,6 +14,35 @@ cmd_exists ()
which $1 2>/dev/null >&2
}
+get_git_branch ()
+{
+ echo $(git branch 2>&- | grep -E '^\* ' | cut -c3-)
+}
+
+get_git_status ()
+{
+ ## GIT TRACKING ##
+ if [ "$GITCHECK" != "" ]
+ then
+ GITBRANCH=$(get_git_branch);
+ if [ "$GITBRANCH" != "" ]
+ then
+ preprint "Checking git status..."
+ _git_status=$(git-runstatus 2>&- | grep -E '^# ([[:alpha:]]+ )+(but not|to be)( [[:alpha:]]+)+:$')
+ if [ "$(grep "but not" <<< $_git_status)" != "" ] ; then
+ COLOR_GIT=$COLOR_NOT_UP_TODATE
+ elif [ "$(grep "to be committed" <<< $_git_status)" != "" ] ; then
+ COLOR_GIT=$COLOR_TOBE_COMMITED
+ else
+ COLOR_GIT=$COLOR_BRANCH_OR_REV
+ fi
+
+ fi
+ fi
+ GitBranch=${GITBRANCH:+:$GITBRANCH}
+ GITBRANCH=${GITBRANCH:+$C_$COLOR_DOUBLEDOT$_C:$C_$COLOR_GIT$_C$GITBRANCH}
+}
+
normal_user ()
{
if [ -e /etc/login.defs ]