zsh-users
 help / color / mirror / code / Atom feed
* positioning of RPS1
@ 2018-03-24 18:44 Ray Andrews
  2018-03-24 23:20 ` Grant Taylor
  2018-03-25 16:36 ` Ray Andrews
  0 siblings, 2 replies; 4+ messages in thread
From: Ray Andrews @ 2018-03-24 18:44 UTC (permalink / raw)
  To: Zsh Users


In my .zshrc:


_blu=$'%{\e[1;34m%}'

_mag=$'%{\e[1;35m%}'

PS1=$'\n$_tty $_blu%d $_mag%L%{\e[0m%}$ %{\e[0m%}'

RPS1=$'%t %w'

... and all's well but editing the name of the color variables:

blu=$'%{\e[1;34m%}'

mag=$'%{\e[1;35m%}'

PS1=$'\n$_tty $blu%d $mag%L%{\e[0m%}$ %{\e[0m%}'

RPS1=$'%t %w'

... now RPS1 is not on the right margin but somewhat to the left.  I 
remember reading something about zsh needing to calculate the actual 
width of the promps but I can't find it.  Does someone have a fast fix, 
or a reference in the docs? Tx.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: positioning of RPS1
  2018-03-24 18:44 positioning of RPS1 Ray Andrews
@ 2018-03-24 23:20 ` Grant Taylor
  2018-03-25 16:36 ` Ray Andrews
  1 sibling, 0 replies; 4+ messages in thread
From: Grant Taylor @ 2018-03-24 23:20 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

On 03/24/2018 12:44 PM, Ray Andrews wrote:
> I remember reading something about zsh needing to calculate the actual 
> width of the promps but I can't find it.  Does someone have a fast fix, 
> or a reference in the docs?

I don't have a fast fix but I do recall what you're talking about.

I think the trick was to put non-printing characters (like escape 
sequences) inside of "%{…}" sequences.  That tells Zsh not to use 
characters in that sequence as printable characters when calculating the 
prompt width.  I believe the same thing applies to both PROMPT and RPROMPT.



-- 
Grant. . . .
unix || die


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 3982 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: positioning of RPS1
  2018-03-24 18:44 positioning of RPS1 Ray Andrews
  2018-03-24 23:20 ` Grant Taylor
@ 2018-03-25 16:36 ` Ray Andrews
  2018-03-25 18:42   ` Grant Taylor
  1 sibling, 1 reply; 4+ messages in thread
From: Ray Andrews @ 2018-03-25 16:36 UTC (permalink / raw)
  To: Zsh Users

I think the trick was to put non-printing characters (like escape 
sequences) inside of "%{…}" sequences. That tells Zsh not to use 
characters in that sequence as printable characters when calculating the 
prompt width. I believe the same thing applies to both PROMPT and RPROMPT.


Thanks Grant, that's what I was hunting for: %{ ... %}.  Interesting that it
effects RPS1, I'd have thought that it sorta just attaches itself to the right
margin and that the width of PS1 wouldn't matter to it that much, but I suppose
that's naive, the entire prompt is worked out in one calculation.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: positioning of RPS1
  2018-03-25 16:36 ` Ray Andrews
@ 2018-03-25 18:42   ` Grant Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Taylor @ 2018-03-25 18:42 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 997 bytes --]

On 03/25/2018 10:36 AM, Ray Andrews wrote:
> I think the trick was to put non-printing characters (like escape 
> sequences) inside of "%{…}" sequences. That tells Zsh not to use 
> characters in that sequence as printable characters when calculating the 
> prompt width. I believe the same thing applies to both PROMPT and RPROMPT.

Thank you for the confirmation.

> Thanks Grant, that's what I was hunting for: %{ ... %}.  Interesting that 
> it effects RPS1, I'd have thought that it sorta just attaches itself to 
> the right margin and that the width of PS1 wouldn't matter to it that 
> much, but I suppose that's naive, the entire prompt is worked out in 
> one calculation.

You're welcome.  I'm glad that you got it working.

Depending on window width, prompt & command length, Zsh will remove the 
RPROMPT when the command gets too close.  As such Zsh needs to know the 
printed width of the RPROMPT just like the (L)PROMPT.



-- 
Grant. . . .
unix || die


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 3982 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-25 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-24 18:44 positioning of RPS1 Ray Andrews
2018-03-24 23:20 ` Grant Taylor
2018-03-25 16:36 ` Ray Andrews
2018-03-25 18:42   ` Grant Taylor

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).