From 8f6bc5b80619fb51e43f7718a4886cf9823a35b4 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Fri, 28 Sep 2007 11:36:36 +0200 Subject: "Modularized" and automagic on-demand git-status. Conflicts: .zsh/01_Functions.zsh .zsh/11_Prompts.zsh .zsh/user:hugues/KeyBindings.zsh --- 01_Functions.zsh | 32 ++++++++++++++++++++++++++++++-- 11_Prompts.zsh | 25 +------------------------ user:hugues/KeyBindings.zsh | 4 ++-- 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,21 +14,49 @@ 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-) } 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" -- cgit v1.2.3