summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2008-03-06 13:10:18 +0100
committerHugues Hiegel <hugues@hiegel.fr>2008-03-07 14:15:22 +0100
commit8cddca0a5c4cf1f569ecaf49afc52113768d2045 (patch)
tree214f67122d2f28a28a4d6d1dafe3daf08caa305e
parent01b047c344ae35bb55fe211aa5e65d0e99acc75a (diff)
Brouillon.
-rw-r--r--11_Prompts.zsh39
1 files 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