Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: On the topic of prompts
- X-seq: zsh-users 287
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: DeWitt Clinton <dewitt@xxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: On the topic of prompts
- Date: Thu, 11 Jul 1996 16:00:33 -0700
- In-reply-to: DeWitt Clinton <dewitt@xxxxxxxxxxxxxxx> "On the topic of prompts" (Jul 11, 1:51pm)
- References: <Pine.LNX.3.94.960711134215.3905A-100000@xxxxxxxxxxxxxxx>
- Reply-to: schaefer@xxxxxxx
On Jul 11, 1:51pm, DeWitt Clinton wrote:
> Subject: On the topic of prompts
>
> Since there is probably no way to justify a section of the prompt, perhaps
> there is a way to tell rprompt to write to the line just above using
> control characters? Just wondering...
Sure. Note that the following won't work properly if you don't have a
newline in PS1.
RPS1="%{$(echotc ku)%}whatever you want here%{$(echotc kd)%}"
You might have to replace $(echotc ku) and $(echotc kd) with different
up and down escapes for your terminal if your terminal has a keypad
transmit mode, because keypad mode is normally not in use.
I tried $(echotc up) and $(echotc do) but that doesn't work because "do"
is frequently just ctrl-J, which zsh strips out of rprompts.
> Also, is there a way to pad the variables with spaces? If so, that would
> solve this problem entirely.
Sort of.
precmd() {
fakePS1=$(print -nP " %h %m %n %~ %W")
unset fakeRPS1 # Clear any previous `typeset -R`
fakeRPS1=$(print -nP %@)
if [[ $[$COLUMNS-$#fakePS1-$#fakeRPS1-2] -gt 0 ]]
then
typeset -R $[$COLUMNS-$#fakePS1-1] fakeRPS1="$fakeRPS1"
PS1="$fakePS1$fakeRPS1
% "
else
PS1="$fakePS1
% "
fi
}
> While I am thinking about it, what I am really looking for is a status bar
> that would just sit at the top of the screen and hold certain useful
> information. Anyone know of how to achieve this?
You can play all sorts of games with %{...%} and termcap sequences if
your terminal can set scrolling regions and so forth. If you're using
an xterm, you can use something like this to change the title bar:
if [[ "$TERM" = xterm* || "$TERM" = vs100 || "$TERM" = vs100s ]]
then
# Set top to introduce titlebar change
top=']0;'
# Set back to end titlebar change
back=''
# Create precmd() to put stuff in the title bar
precmd() { print -nP "%{$top%m.%l:%2c - %t$back%}" }
fi
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
New male in /home/schaefer:
>N 2 Justin William Schaefer Sat May 11 03:43 53/4040 "Happy Birthday"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author