From 8cddca0a5c4cf1f569ecaf49afc52113768d2045 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 6 Mar 2008 13:10:18 +0100 Subject: Brouillon. --- 11_Prompts.zsh | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/11_Prompts.zsh b/11_Prompts.zsh index 1b47bc1..21eb85d 100644 --- a/11_Prompts.zsh +++ b/11_Prompts.zsh @@ -79,37 +79,50 @@ preexec () } GITCHECK=${GITCHECK:-} -#SVNCHECK=${SVNCHECK:-} -#unset GITCHECK SVNCHECK expand_text() { print -Pn -- "$(echo $@ | sed 's/%{[^(%})]*%}//g')" } -precmd () +new_precmd() { + # + # Arrays + # [0] prompt-style string + # [1] total size + # [2] color + # [3] pre-string + # [4] post-string + # + typeset -A ERROR DATE MAILS LOGIN HOST CWD GITINFO SVNINFO PROMPT +} + +old_precmd() +{ + # Error error=$(print -Pn "%(?;;-%?)") ERRORSIZE=${#error} ERROR="%(?;;"$C_$COLOR_BAR$_C"-"$C_$COLOR_ERRR$_C"%?)" DATE=$C_$COLOR_BRACES$_C"[ "$C_$COLOR_DATE$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$COLOR_BRACES$_C" ]"$C_$COLOR_BAR$_C"-" - DATEEXPAND=$(expand_text "$DATE") - DATESIZE=${#DATEEXPAND} + # Flush the term title term_title - # + # Date + DATEEXPAND=$(expand_text "$DATE") + DATESIZE=${#DATEEXPAND} + # Mailcheck MAILSTAT=$(eval echo "`[ -s ~/.procmail/procmail.log ] && < ~/.procmail/procmail.log awk 'BEGIN {RS="From" ; HAM=-1} !/JUNK/ { HAM++ } END { if (HAM > 0) { print "$C_$COLOR_BAR$_C""-""$C_$COLOR_MAIL$_C""@" } }'`") MAILSTATEXPAND=$(expand_text "$MAILSTAT") MAILSTATSIZE=${#MAILSTATEXPAND} + # get git status check_git_status - #echo "$DATESIZE - $ERRORSIZE - $MAILSTATSIZE" - - ## First line of prompt : + # First line of prompt, calculation of the remaining place spaceleft=$((1 + $COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE)) unset HBAR @@ -117,10 +130,9 @@ precmd () do HBAR=$HBAR- done + # ## Second line of prompt : don't let the path garbage the entire line MY_PATH="%(!.%d.%~)" - pathsize=`print -Pn $MY_PATH` - pathsize=${#pathsize} spaceleft=`print -Pn "%n@%m $GitBranch $ ls -laCdtrux $(expand_text "$DATE")"` spaceleft=$(($COLUMNS - ${#spaceleft})) minimalsize=`print -Pn "%1~"` @@ -138,6 +150,11 @@ precmd () } +precmd() +{ + old_precmd +} + chpwd() { which todo > /dev/null 2>&1 && todo -- cgit v1.2.3