From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Ian Lynagh <igloo@earth.li>, zsh-users@sunsite.dk
Subject: Re: Length of %? in prompt
Date: Tue, 26 Feb 2002 17:10:45 +0000 [thread overview]
Message-ID: <1020226171045.ZM9835@candle.brasslantern.com> (raw)
In-Reply-To: <20020226160503.GA15163@stu163.keble.ox.ac.uk>
On Feb 26, 4:05pm, 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 :-(
No, you don't need to do that. You can use the truncation sequences %>>
and/or %<<. Let's assume that you want the value of %? plus the hyphens
to take up a total of 10 characters; you'd use:
%10>-->%?--------%<<
The number of hyphens following %? must be at least 9 in order for the
field to always be 10 characters wide -- truncation won't lengthen the
prompt, only shorten it.
An important thing to note is that %N>STRING> means that STRING replaces
the last strlen(STRING) characters of the remaining prompt, up to %<<,
any time it is more than N characters long. E.g., with %N>--> you can't
make N less than 5 without digits from %? being truncated when the exit
status is more than two digits long.
So the minimal fixed-width replacement for %? using this scheme is:
%4>->%?---%<<
which works out to up to three digits of %? followed by at least 1 hyphen.
You can put the hyphens in front, too, of course:
%4<-<---%?%>>
It's not necessary to reverse the > and < at the beginning and end of the
truncation region, I just do it for visual symmetry. These work too:
%4>->%?---%>>
%4<-<---%?%<<
Finally, you can even do this:
%(?.----.%4>->%?---)
Here, the truncation ends at the closing paren. This example does not
show the exit status unless it is nonzero.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
next prev parent reply other threads:[~2002-02-26 17:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-26 16:05 Ian Lynagh
2002-02-26 16:48 ` Peter Stephenson
2002-02-26 17:10 ` Bart Schaefer [this message]
2002-02-26 18:08 ` Ian Lynagh
2002-02-26 18:26 ` Bart Schaefer
2002-02-26 18:42 ` Ian Lynagh
2002-02-26 19:21 ` Bart Schaefer
2002-02-28 15:34 ` Ian Lynagh
2002-02-28 16:45 ` Bart Schaefer
2002-02-28 17:12 ` Ian Lynagh
2002-02-28 21:00 ` Bart Schaefer
2002-03-01 12:38 ` Ian Lynagh
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=1020226171045.ZM9835@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=igloo@earth.li \
--cc=zsh-users@sunsite.dk \
/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).