summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2007-09-28 11:36:36 +0200
committerHugues Hiegel <hugues@hiegel.fr>2008-03-07 14:15:18 +0100
commit8f6bc5b80619fb51e43f7718a4886cf9823a35b4 (patch)
tree5184311bc9a2a44f0eb71fbe45151be230961b86
parent9274321f6a355957057150175346acf2e7e6cd18 (diff)
"Modularized" and automagic on-demand git-status.
Conflicts: .zsh/01_Functions.zsh .zsh/11_Prompts.zsh .zsh/user:hugues/KeyBindings.zsh
-rw-r--r--01_Functions.zsh32
-rw-r--r--11_Prompts.zsh25
-rw-r--r--user:hugues/KeyBindings.zsh4
3 files changed, 33 insertions, 28 deletions
diff --git a/01_Functions.zsh b/01_Functions.zsh
index a8973e7..66ed509 100644
--- a/01_Functions.zsh
+++ b/01_Functions.zsh
@@ -14,6 +14,29 @@ cmd_exists ()
which $1 2>/dev/null >&2
}
+term_title()
+{
+ [[ -t 1 ]] &&
+ case $TERM in
+ sun-cmd)
+ print -Pn "\e]l%n@%m %~$1\e\\" ;;
+ *term*|rxvt*)
+ print -Pn "\e]0;%n@%m (%l) %~$1\a" ;;
+ *)
+ ;;
+ esac
+}
+
+preprint()
+{
+ hbar=
+ for i in {1..$(($COLUMNS - ${#1} - 5))}
+ do
+ hbar=$hbar-
+ done
+ print -Pn "${C_}0;30;1${_C}${hbar}[ $1 ]-\r${C_}0${_C}"
+}
+
get_git_branch ()
{
echo $(git branch 2>&- | grep -E '^\* ' | cut -c3-)
@@ -21,14 +44,19 @@ get_git_branch ()
get_git_status ()
{
+ git-status
+ check_git_status
+}
+
+check_git_status ()
+{
## GIT TRACKING ##
if [ "$GITCHECK" != "" ]
then
GITBRANCH=$(get_git_branch);
- TEE=""
if [ "$GITBRANCH" != "" ]
then
- preprint "Checking git status..."
+ preprint "Check 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
diff --git a/11_Prompts.zsh b/11_Prompts.zsh
index d3b4062..5ca1a02 100644
--- a/11_Prompts.zsh
+++ b/11_Prompts.zsh
@@ -71,19 +71,6 @@ COLOR_DATE="0;$GENERIC"
# precmd : avant d'afficher le prompt
#
-term_title()
-{
- [[ -t 1 ]] &&
- case $TERM in
- sun-cmd)
- print -Pn "\e]l%n@%m %~$1\e\\" ;;
- *term*|rxvt*)
- print -Pn "\e]0;%n@%m (%l) %~$1\a" ;;
- *)
- ;;
- esac
-}
-
preexec ()
{
term_title " ยทยทยท $(echo $1 | tr ' \n' ' ;' | sed 's/%/%%/g;s/\\/\\\\/g')"
@@ -94,16 +81,6 @@ GITCHECK=${GITCHECK:-yeah}
#SVNCHECK=${SVNCHECK:-yeah}
#unset GITCHECK SVNCHECK
-preprint()
-{
- hbar=
- for i in {1..$(($COLUMNS - ${#1} - 5))}
- do
- hbar=$hbar-
- done
- print -Pn "${C_}0;30;1${_C}${hbar}[ $1 ]-\r"
-}
-
precmd ()
{
term_title
@@ -162,7 +139,7 @@ precmd ()
chpwd()
{
which todo > /dev/null 2>&1 && todo
- get_git_status
+ check_git_status
}
diff --git a/user:hugues/KeyBindings.zsh b/user:hugues/KeyBindings.zsh
index 78eb3db..274825b 100644
--- a/user:hugues/KeyBindings.zsh
+++ b/user:hugues/KeyBindings.zsh
@@ -218,5 +218,5 @@ bindkey -s "l" "  l\n"
bindkey -s " " "\\\\ "
-bindkey -s "g" "  git-status ; get_git_status\n"
-bindkey -s "G" "  GITBRANCH=\n"
+bindkey -s "g" " get_git_status\n"
+bindkey -s "G" "  GITCHECK= GITBRANCH=\n"