Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: ztrftime %. for fractions of a second in prompts



On Wed, 30 Jul 2014 11:46:51 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> I was trying to get some timings in prompts to better than a second ---
> not particularly useful in a regular shell prompt, but very useful in
> the prompts provided by e.g. the TCP functions.

This requires some further massaging.

pws


diff --git a/Doc/Zsh/tcpsys.yo b/Doc/Zsh/tcpsys.yo
index 599335b..1e26054 100644
--- a/Doc/Zsh/tcpsys.yo
+++ b/Doc/Zsh/tcpsys.yo
@@ -666,6 +666,10 @@ expression `tt(%c)' expands to 1 if the session being read is the current
 session, else 0; this is most useful in ternary expressions such as
 `tt(%LPAR()c.-.PLUS()RPAR())' which outputs `tt(PLUS())' if the session is
 the current one, else `tt(-)'.
+
+If the prompt starts with tt(%P), this is stripped and the complete
+result of the previous stage is passed through standard prompt tt(%)-style
+formatting before being output.
 )
 vindex(TCP_READ_DEBUG)
 item(tt(TCP_READ_DEBUG))(
diff --git a/Functions/TCP/tcp_output b/Functions/TCP/tcp_output
index 781c46c..22e818e 100644
--- a/Functions/TCP/tcp_output
+++ b/Functions/TCP/tcp_output
@@ -35,6 +35,9 @@ if [[ -n $tprompt ]]; then
       cursess="c:0"
   fi
   zformat -f REPLY $tprompt "s:$sess" "f:$read_fd" $cursess
+  if [[ $REPLY = %P* ]]; then
+    REPLY=${(%)${REPLY##%P}}
+  fi
   # We will pass this back up.
   REPLY="$REPLY$*"
 else



Messages sorted by: Reverse Date, Date, Thread, Author