summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2008-10-30 17:36:03 +0100
committerHugues Hiegel <hugues@hiegel.fr>2008-10-30 17:51:17 +0100
commit37ff7a349f01d1d9c60064b39903b8457b37e06b (patch)
tree90b42420331e4900709b3aec7db5ab52086a4639
parent73de8ecfe9d49c9045ff07cab911c02c6a936eda (diff)
Redisplays prompt with current time before executing a command
-rw-r--r--12_Prompts.zsh25
1 files changed, 17 insertions, 8 deletions
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index ef9f319..79d0c0b 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -22,17 +22,27 @@ set_prompt_colors $prompt_colors[generic]
# precmd : avant d'afficher le prompt
#
+expand_text()
+{
+ # strips the %{...%}
+ print -Pn -- "$(echo $@ | sed 's/%{[^(%})]*%}//g')"
+}
+
preexec ()
{
local my_sep=$([ "$TERM" = "putty" ] && echo "---" || echo "ยทยทยท")
term_title " $my_sep $(echo $1 | tr ' \n' ' ;' | sed 's/%/%%/g;s/\\/\\\\/g')"
print -Pn "$C_$prompt_colors[exec]$_C"
-}
-expand_text()
-{
- # strips the %{...%}
- print -Pn -- "$(echo $@ | sed 's/%{[^(%})]*%}//g')"
+ prompt_colors[date]="$prompt_colors[generic];$color[bold]"
+ update_prompt
+
+ local string="$(expand_text "$PROMPT$1")"
+ local lines=$(( (${#string} - 1) / $COLUMNS))
+ for i in {0..$lines} ; print -Pn "\e[1A"
+ print -Pn "\r$PROMPT"
+ print "$1"
+ prompt_colors[date]=$prompt_colors[generic]
}
new_precmd()
@@ -53,7 +63,7 @@ new_precmd()
ERROR[size] = ${#$(print -Pn $ERROR[pre]$ERROR[string]$ERROR[post])}
}
-old_precmd()
+update_prompt()
{
# Error
error=$(print -Pn "%(?;;-%?)")
@@ -166,12 +176,11 @@ old_precmd()
PS1="$MAILSTAT""$ERROR"$C_$prompt_colors[bar]$_C"$HBAR""$DATE
"$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m $CURDIR$SVNREV$GITBRANCH "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" "
-
}
precmd()
{
- old_precmd
+ update_prompt
}
chpwd()