zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: PATCH: ztrftime %. for fractions of a second in prompts
Date: Wed, 30 Jul 2014 12:21:54 +0100	[thread overview]
Message-ID: <20140730122154.1a4346a8@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20140730114651.5687f4df@pwslap01u.europe.root.pri>

On Wed, 30 Jul 2014 11:46:51 +0100
Peter Stephenson <p.stephenson@samsung.com> 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


  reply	other threads:[~2014-07-30 11:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-30 10:46 Peter Stephenson
2014-07-30 11:21 ` Peter Stephenson [this message]
2014-07-30 13:16 ` Vin Shelton
2014-07-30 13:24   ` Peter Stephenson
2014-07-30 13:56     ` Vin Shelton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140730122154.1a4346a8@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).