summaryrefslogtreecommitdiff
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
parent68f04afba2bfd7570aa9a34ef01b4bc87b0d1fb0 (diff)
on-demand git-status (with M-g, and M-G to clear)
-rw-r--r--01_Functions.zsh29
-rw-r--r--11_Prompts.zsh23
-rw-r--r--user:hugues/KeyBindings.zsh3
3 files changed, 33 insertions, 22 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 ]
diff --git a/11_Prompts.zsh b/11_Prompts.zsh
index a0a2feb..d3b4062 100644
--- a/11_Prompts.zsh
+++ b/11_Prompts.zsh
@@ -114,28 +114,6 @@ precmd ()
ERROR=%(? "$C_$COLOR_BAR$_C----" "%4>>"$C_$COLOR_ERRR$_C"%?$C_$COLOR_BAR$_C"---"%>>")
errorsize=4
- ## GIT TRACKING ##
- unset GITBRANCH
- if [ "$GITCHECK" != "" ]
- then
- GITBRANCH=$(git branch 2>&- | grep -E '^\* ' | cut -c3-)
- 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}
-
## SVN TRACKING ##
SVNREV=$(svn info 2>&- | grep '^RĂ©vision : ' | sed 's/^.* : /r/')
if [ "$SVNREV" != "" ]
@@ -184,6 +162,7 @@ precmd ()
chpwd()
{
which todo > /dev/null 2>&1 && todo
+ get_git_status
}
diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh
index 16382cd..4dc48e7 100644
--- a/user:hugues/KeyBindings.zsh
+++ b/user:hugues/KeyBindings.zsh
@@ -217,3 +217,6 @@ bindkey -s "l" "  l\n"
#bindkey -s "L" "  la\n"
bindkey -s " " "\\\\ "
+
+bindkey -s "g" "  get_git_status\n"
+bindkey -s "G" "  GITBRANCH=\n"