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

Re: Length of %? in prompt

Ian Lynagh wrote:
> If the length of %? will alter the number of dashes following it in my
> prompt am I right in thinking that my only course of action is to
> enumerate the (rather large!) set of possible cases with
> "%(n?,---...,)"? If so I guess I will have to redesign  :-(

I haven't understood quite what you're trying to do, but you might be
able to use truncation.

  "%10>>anything%>>something else"

will limit `anything', whatever it expands to (it can include arbitrary
prompt escapes but also any other text), to 10 characters, truncating on
ther right.  Truncation is then turned off so that `something else' will
be output in full.  So to keep the length the same you can arrange for
`anything' to end with an arbitrarily large string of characters which
will be pruned to the right size.

This assumes zsh 4.  The truncation in older versions was less flexible
--- only the replacement text for prompt escapes was truncated.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

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