zsh-users
 help / color / mirror / code / Atom feed
* Wish for rprompt feature
@ 2004-03-19 11:41 Thorsten Kampe
  2004-03-20 17:10 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Thorsten Kampe @ 2004-03-19 11:41 UTC (permalink / raw)
  To: zsh-users

Reading the User's Guide again[1] an idea came to my mind that would
compensate for an inability of the current implementation of the
"right prompt":

I have my pwd ("%~") in my RPROMPT (as probably many people). When the
path to the pwd is long (or I type a long command line) the rprompt
disappears and makes place for my typing.

This is a feature and generally a good thing but the problem is that
the /whole/ rprompt disappears and not just the space I need.

Just a "picture" for what I would like:

current:
thorsten@galactus% 12345678 /cygdrive/g/home/thorsten/ifolder/gentoo/conf/kernel
thorsten@galactus% 123456789

desired:
thorsten@galactus% 12345678 /cygdrive/g/home/thorsten/ifolder/gentoo/conf/kernel
thorsten@galactus% 123456789 [...]/g/home/thorsten/ifolder/gentoo/conf/kernel
thorsten@galactus% 1234567890  [...]/home/thorsten/ifolder/gentoo/conf/kernel

Is that already possible? Or an easy to implement case for the
wishlist?

Thanks,
Thorsten

[1] "Prompts or parts of prompts, not just bits showing the directory,
can be truncated to any length you choose. To truncate a path on the
left, use something like ‘%10<...<%~’. That works like this: the
‘%<<’ is the basic form for truncation. The 10 after the ‘%’ says
that anything following is limited to 10 characters, and the
characters ‘...’ are to be displayed whenever the prompt would
otherwise be longer than that (you can leave this empty). This
applies to anything following, so now the %~ can’t be longer than 10
characters, otherwise it will be truncated (to 7 characters, once the
‘...’ has been printed)."


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

* Re: Wish for rprompt feature
  2004-03-19 11:41 Wish for rprompt feature Thorsten Kampe
@ 2004-03-20 17:10 ` Bart Schaefer
  2004-03-20 18:12   ` Thorsten Kampe
  2004-03-20 19:28   ` Wayne Davison
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 2004-03-20 17:10 UTC (permalink / raw)
  To: zsh-users

On Mar 19, 12:41pm, Thorsten Kampe wrote:
}
} I have my pwd ("%~") in my RPROMPT (as probably many people). When the
} path to the pwd is long (or I type a long command line) the rprompt
} disappears and makes place for my typing.
} 
} This is a feature and generally a good thing but the problem is that
} the /whole/ rprompt disappears and not just the space I need.

Have you looked at some of the "prompt themes" that come with recent zsh?
A couple of them include two-line prompts that put the working directory
on the upper line, out of the way.

E.g. my prompt (the "bart" theme in the distribution) looks like this
(I've narrowed it to a 70 column terminal in hopes of avoiding line
wrap):

zagzig [cvstat] /usr/src/local/zsh/zsh-4.0           04-03-20  8:47AM
schaefer[603]                                                   4.0.6

Only the zsh version (4.0.6) is in the "real" RPS1, everything else is in
PS1, but the date and time at upper right behave like an rprompt in that
they'll disappear if the previous command (in brackets -- cvstat is an
alias that runs "cvs status" through a sed script) or the directory name
get too long.  The prompt will even go to three lines if it must:

zagzig /usr/src/local/zsh/zsh-4.0                    04-03-20  8:53AM
[echo this is a really long command string for example]
schaefer[605]                                                   4.0.6

And the various bits are all differently colored, too which obviously you
can't see in this email.  By the way, running "prompt bart" just adds the
upper line to your existing PS1 and RPS1 -- it doesn't change the lower-
left part -- so to get the above effect I use

PS1='%n[%h] '
RPS1=$ZSH_VERSION
prompt bart

The other theme that does something similar is "clint".


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

* Re: Wish for rprompt feature
  2004-03-20 17:10 ` Bart Schaefer
@ 2004-03-20 18:12   ` Thorsten Kampe
  2004-03-21  1:29     ` Bart Schaefer
  2004-03-20 19:28   ` Wayne Davison
  1 sibling, 1 reply; 8+ messages in thread
From: Thorsten Kampe @ 2004-03-20 18:12 UTC (permalink / raw)
  To: zsh-users

* Bart Schaefer (2004-03-20 18:10 +0100)
> On Mar 19, 12:41pm, Thorsten Kampe wrote:
> } I have my pwd ("%~") in my RPROMPT (as probably many people). When the
> } path to the pwd is long (or I type a long command line) the rprompt
> } disappears and makes place for my typing.
> } 
> } This is a feature and generally a good thing but the problem is that
> } the /whole/ rprompt disappears and not just the space I need.
> 
> Have you looked at some of the "prompt themes" that come with recent zsh?
> A couple of them include two-line prompts that put the working directory
> on the upper line, out of the way.

Thanks, but I'd like to keep a one line prompt (that's the main reason
for using rprompt at all) and I'd like to use rprompt because it
already does everything I want (except the thing I mentioned).

Customising your prompt so that it works like rprompt plus the "[...]"
would require zsh skills beyond mine.

Thorsten


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

* Re: Wish for rprompt feature
  2004-03-20 17:10 ` Bart Schaefer
  2004-03-20 18:12   ` Thorsten Kampe
@ 2004-03-20 19:28   ` Wayne Davison
  2004-03-21  0:00     ` Bart Schaefer
  1 sibling, 1 reply; 8+ messages in thread
From: Wayne Davison @ 2004-03-20 19:28 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

On Sat, Mar 20, 2004 at 05:10:38PM +0000, Bart Schaefer wrote:
> PS1='%n[%h] '
> RPS1=$ZSH_VERSION
> prompt bart

If I use "prompt bart", the spacing prior to the date is missing and I
get this error:

prompt_bart_precmd:14: : parameter not set

I added "unset" to the "setopt localoptions" in prompt_bart_precmd and
the error went away.  Is that the right fix?

..wayne..


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

* Re: Wish for rprompt feature
  2004-03-20 19:28   ` Wayne Davison
@ 2004-03-21  0:00     ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2004-03-21  0:00 UTC (permalink / raw)
  To: zsh-users

On Mar 20, 11:28am, Wayne Davison wrote:
} Subject: Re: Wish for rprompt feature
}
} If I use "prompt bart", the spacing prior to the date is missing and I
} get this error:
} 
} prompt_bart_precmd:14: : parameter not set
} 
} I added "unset" to the "setopt localoptions" in prompt_bart_precmd and
} the error went away.  Is that the right fix?

Yes, that is the right fix.  I have it in my copy here at home, but I
apparently never remembered to commit it. :-(

Index: Functions/Prompts/prompt_bart_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_bart_setup,v
retrieving revision 1.6
diff -u -r1.6 prompt_bart_setup
--- Functions/Prompts/prompt_bart_setup 11 Apr 2001 22:25:27 -0000      1.6
+++ Functions/Prompts/prompt_bart_setup 20 Mar 2004 23:49:03 -0000
@@ -58,7 +58,7 @@
 }
 
 prompt_bart_precmd () {
-    setopt localoptions noxtrace noksharrays
+    setopt localoptions noxtrace noksharrays unset
     local zero='%([BSUbsu]|{*%})'
 
     # Using psvar here protects against unwanted promptsubst expansions.
@@ -111,7 +111,7 @@
 }
 
 prompt_bart_winch () {
-    setopt localoptions noksharrays
+    setopt localoptions noksharrays unset
 
     # Delete ourself from TRAPWINCH if not using our precmd insert.
     [[ $functions[precmd] = *prompt_bart_precmd* ]] && prompt_bart_ps1 ||
@@ -119,7 +119,7 @@
 }
 
 prompt_bart_setup () {
-    setopt localoptions noksharrays
+    setopt localoptions noksharrays unset
 
     # A few extra niceties ...
     repeat 1 case "$1:l" in


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

* Re: Wish for rprompt feature
  2004-03-20 18:12   ` Thorsten Kampe
@ 2004-03-21  1:29     ` Bart Schaefer
  2004-03-24 20:25       ` Thorsten Kampe
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2004-03-21  1:29 UTC (permalink / raw)
  To: zsh-users

On Mar 20,  7:12pm, Thorsten Kampe wrote:
} 
} Customising your prompt so that it works like rprompt plus the "[...]"
} would require zsh skills beyond mine.

It'd require skills beyond mine, too, without modifying the C code.  As
usual with zsh prompts, RPS1 is computed exactly once (before the line
editor starts up for each command) and thereafter the code only knows
how long it is, to know when the input line overlaps with it and hence
to stop showing it.

However, try this (requires 4.2.0) and see what you think:

zle-line-init() {
  POSTDISPLAY="  ${(%)RPS1}"
}
zle -N zle-line-init

Adjust spacing as you see fit.


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

* Re: Wish for rprompt feature
  2004-03-21  1:29     ` Bart Schaefer
@ 2004-03-24 20:25       ` Thorsten Kampe
  2004-03-25  3:07         ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Thorsten Kampe @ 2004-03-24 20:25 UTC (permalink / raw)
  To: zsh-users

* Bart Schaefer (2004-03-21 02:29 +0100)
> On Mar 20,  7:12pm, Thorsten Kampe wrote:
> } Customising your prompt so that it works like rprompt plus the "[...]"
> } would require zsh skills beyond mine.
> 
> It'd require skills beyond mine, too, without modifying the C code.  As
> usual with zsh prompts, RPS1 is computed exactly once (before the line
> editor starts up for each command) and thereafter the code only knows
> how long it is, to know when the input line overlaps with it and hence
> to stop showing it.
> 
> However, try this (requires 4.2.0) and see what you think:
> 
> zle-line-init() {
>   POSTDISPLAY="  ${(%)RPS1}"
> }
> zle -N zle-line-init

Looks interesting. But I cannot test your solution as thoroughly as it
deserves because it doesn't recognize the Prompt sequences in my
rprompt ($cyan, $reset_color[1]).

Could you modify your "zle-line-init/POSTDISPLAY" solution so the
colours in my prompt are shown?


Thanks, Thorsten

[1] 
 [~/.zshrc]
 autoload -U colors; colors
 cyan=$fg_no_bold[cyan]
 RPROMPT='%{$cyan%}%~%{$reset_color%} %h:%i'


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

* Re: Wish for rprompt feature
  2004-03-24 20:25       ` Thorsten Kampe
@ 2004-03-25  3:07         ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2004-03-25  3:07 UTC (permalink / raw)
  To: zsh-users

On Mar 24,  9:25pm, Thorsten Kampe wrote:
} Subject: Re: Wish for rprompt feature
}
} * Bart Schaefer (2004-03-21 02:29 +0100)
} >   POSTDISPLAY="  ${(%)RPS1}"
} 
} Looks interesting. But I cannot test your solution as thoroughly as it
} deserves because it doesn't recognize the Prompt sequences in my
} rprompt ($cyan, $reset_color[1]).

Ah.  Well, the short answer _should_ have been "change (%) to (%%) to
enable full prompt expansions" ... but it appears POSTDISPLAY does not
output the value verbatim, but rather prints it as if ${(V)POSTDISPLAY}
had been used.

So ...

} Could you modify your "zle-line-init/POSTDISPLAY" solution so the
} colours in my prompt are shown?

Apparently not.


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

end of thread, other threads:[~2004-03-25  3:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-19 11:41 Wish for rprompt feature Thorsten Kampe
2004-03-20 17:10 ` Bart Schaefer
2004-03-20 18:12   ` Thorsten Kampe
2004-03-21  1:29     ` Bart Schaefer
2004-03-24 20:25       ` Thorsten Kampe
2004-03-25  3:07         ` Bart Schaefer
2004-03-20 19:28   ` Wayne Davison
2004-03-21  0:00     ` Bart Schaefer

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