summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2008-03-06 02:10:08 +0100
committerHugues Hiegel <hugues@hiegel.fr>2008-03-07 14:15:22 +0100
commitf8e6ea809bc3cbed800a3fef87a58af4f96fda59 (patch)
tree0b50c299d01ca263ea87004c435a9f8e24adddd1
parent38bf2f7c5d1a357234e8360baff7dfbaa4d28b59 (diff)
=?utf-8?q?Enfin=20un=20vrai=20calcul=20de=20la=20place=20dispo=20selon=20le=20code=20d'erreur
=20et=20le=20statut=20des=20mails,=20avec=20du=20code=20bien=20plus=20propre. =20Affichage=20beaucoup=20plus=20"rang=C3=A9"=20de=20ces=20diff=C3=A9rents=20flags. =20TODO:=20attaquer=20la=20seconde=20ligne=20du=20prompt.?= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1.5.4.1" This is a multi-part message in MIME format. --------------1.5.4.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit
-rw-r--r--11_Prompts.zsh49
1 files changed, 21 insertions, 28 deletions
diff --git a/11_Prompts.zsh b/11_Prompts.zsh
index 7239b34..863d91f 100644
--- a/11_Prompts.zsh
+++ b/11_Prompts.zsh
@@ -82,48 +82,41 @@ GITCHECK=${GITCHECK:-}
#SVNCHECK=${SVNCHECK:-}
#unset GITCHECK SVNCHECK
+expand_text()
+{
+ print -Pn -- "$(echo $@ | sed 's/%{[^(%})]*%}//g')"
+}
+
precmd ()
{
- term_title
+ 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}
- DATE="%D{%a %d %b %Y %H:%M:%S}"
- datesize=`print -Pn $DATE`
- datesize=${#datesize}
- ERROR=%(? "$C_$COLOR_BAR$_C----" "%4>>"$C_$COLOR_ERRR$_C"%?$C_$COLOR_BAR$_C"---"%>>")
- errorsize=4
+ term_title
+ #
# Mailcheck
- MAILSTAT="`[ -s ~/.procmail/procmail.log ] && < ~/.procmail/procmail.log awk 'BEGIN {RS="From" ; HAM=-1} !/JUNK/ { HAM++ } END { if (HAM > 0) { print "@" } }'`"
-
-
- ## SVN TRACKING ##
- SVNREV=$(svn info 2>&- | grep '^Révision : ' | sed 's/^.* : /r/')
- if [ "$SVNREV" != "" ]
- then
- if [ "$SVNCHECK" != "" ] && ( preprint "Checking svn status..." ; [ $(svn status 2>&- | grep -v '^?' | wc -l) -gt 0 ] )
- then
- COLOR_SVN=$COLOR_NOT_UP_TODATE
- else
- COLOR_SVN=$COLOR_BRANCH_OR_REV
- fi
- else
- SVNREV=
- fi
+ 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}
check_git_status
+ #echo "$DATESIZE - $ERRORSIZE - $MAILSTATSIZE"
+
## First line of prompt :
- #
- # -ERR------------------------git-svn-[ date ]-
- #
- spaceleft=$(($COLUMNS - ${#MAILSTAT} - 1 - ${errorsize} - ${#SVNREV} -3- ${datesize} -3))
+ spaceleft=$((1 + $COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE))
unset HBAR
for h in {1..$(($spaceleft - 1))}
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`
@@ -139,7 +132,7 @@ precmd ()
# Affiche l'user, l'host, le tty et le pwd. Rien que ça...
# Note que pour le pwd, on n'affiche que les 4 derniers dossiers pour éviter
# de pourrir le fenêtre de terminal avec un prompt à rallonge.
- PS1=$C_$COLOR_BAR$_C"-"$C_$COLOR_MAIL$_C"$MAILSTAT"$C_$COLOR_BAR$_C"-$ERROR"$C_$COLOR_BAR$_C"$HBAR"$C_$COLOR_SVN$_C"$SVNREV"$C_$COLOR_BAR$_C"-"$C_$COLOR_BRACES$_C"[ "$C_$COLOR_DATE$_C"$DATE"$C_$COLOR_BRACES$_C" ]"$C_$COLOR_BAR$_C"-
+ PS1="$MAILSTAT""$ERROR"$C_$COLOR_BAR$_C"$HBAR""$DATE
"$C_$COLOR_USER$_C"%n"$C_$COLOR_AROB$_C"@"$C_$COLOR_HOST$_C"%m $CURDIR$GITBRANCH "$C_$COLOR_DIES$_C"%#"$C_$COLOR_CMD$_C" "