* Xterm title changing prompt problem: HELP!
@ 1999-01-14 22:17 Shawn Leas
1999-01-14 23:25 ` Geoff Wing
0 siblings, 1 reply; 8+ messages in thread
From: Shawn Leas @ 1999-01-14 22:17 UTC (permalink / raw)
To: Z Shell Users
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 1087 bytes --]
This new thing I found is too kewl, but I need a little help.
It sets the Xterm title by echoing:
<ESC>]; put string here^G and then the rest of the prompt.
However, my right prompt is shifted to the left. I suspect
This is due to zsh keeping track of the length of the left
part of the prompt, then adjusting where to put the right one.
Should I just not have a right prompt? Or is there a way around
this?
PROMPT='^[];[%l] %n@%m %1v (%h) %t\a[%l] %n@%m %1v (%h) %t '
RPROMPT=' %~'
function precmd {
setopt no_ksh_arrays local_options
case "${${$(uptime)##*"load average: "}%%,*}" in
0.[0-4]*) psvar[1]='%^)' ;;
0.[5-9]*) psvar[1]=';^]' ;;
1.*) psvar[1]=';^|' ;;
2.*) psvar[1]=':^|' ;;
3.*) psvar[1]=':^(' ;;
[45].*) psvar[1]=':^O' ;;
[67].*) psvar[1]='|-P' ;;
*) psvar[1]='|-(' ;;
esac
}
-Shawn
<=========== America Held Hostage ===========>
Day 2185 for the poor and the middle class.
Day 2204 for the rich and the dead.
737 days remaining in the Raw Deal.
<============================================>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Xterm title changing prompt problem: HELP!
1999-01-14 22:17 Xterm title changing prompt problem: HELP! Shawn Leas
@ 1999-01-14 23:25 ` Geoff Wing
1999-01-15 11:48 ` Andrew Gallagher
0 siblings, 1 reply; 8+ messages in thread
From: Geoff Wing @ 1999-01-14 23:25 UTC (permalink / raw)
To: zsh-users
Shawn Leas <sleas@ixion.honeywell.com> typed:
:This new thing I found is too kewl, but I need a little help.
:However, my right prompt is shifted to the left. I suspect
:This is due to zsh keeping track of the length of the left
:part of the prompt, then adjusting where to put the right one.
:Should I just not have a right prompt? Or is there a way around
:this?
:PROMPT='^[];[%l] %n@%m %1v (%h) %t\a[%l] %n@%m %1v (%h) %t '
^ insert ``%{'' ^ insert ``%}''
thus
PROMPT='%{^[];[%l] %n@%m %1v (%h) %t^G%}[%l] %n@%m %1v (%h) %t '
>From the manual (section PROMPT EXPANSION):
%{...%}
Include a string as a literal escape sequence. The
string within the braces should not change the cur-
sor position. Brace pairs can nest.
--
Geoff Wing <gcw@pobox.com> Mobile : 0412 162 441
Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Xterm title changing prompt problem: HELP!
1999-01-14 23:25 ` Geoff Wing
@ 1999-01-15 11:48 ` Andrew Gallagher
1999-01-15 11:58 ` Bruce Stephens
1999-01-15 14:29 ` Geoff Wing
0 siblings, 2 replies; 8+ messages in thread
From: Andrew Gallagher @ 1999-01-15 11:48 UTC (permalink / raw)
To: zsh-users
Geoff Wing wrote:
> Shawn Leas <sleas@ixion.honeywell.com> typed:
> :This new thing I found is too kewl, but I need a little help.
> :However, my right prompt is shifted to the left. I suspect
> :This is due to zsh keeping track of the length of the left
> :part of the prompt, then adjusting where to put the right one.
> :Should I just not have a right prompt? Or is there a way around
> :this?
> :PROMPT='^[];[%l] %n@%m %1v (%h) %t\a[%l] %n@%m %1v (%h) %t '
> ^ insert ``%{'' ^ insert ``%}''
> thus
> PROMPT='%{^[];[%l] %n@%m %1v (%h) %t^G%}[%l] %n@%m %1v (%h) %t '
>
> >From the manual (section PROMPT EXPANSION):
> %{...%}
> Include a string as a literal escape sequence. The
> string within the braces should not change the cur-
> sor position. Brace pairs can nest.
>
Or alternatively, take the escape sequence out of PROMPT and "echo -n" it
from inside the precmd() function ... here is my version:
PROMPT='%? //%n@%B%m%b%//
%l%1v%!> '
RPROMPT='(%T, %w)'
function precmd {
echo -n "^[]0;//$USER@$HOSTNAME$PWD/ ($UNAME)^G"
}
The advantage of this is that it doesn't mess up non-xterm terminals so
much (where the escape sequence will not be recognised and thus _will_
shift the cursor). PROMPT will overwrite the "echo -n"ed line whether it
is printed or not (so long as it is less than 80 chars).
--
Andrew Gallagher
http://members.tripod.com/~AndrewGallagher/id.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Xterm title changing prompt problem: HELP!
1999-01-15 11:48 ` Andrew Gallagher
@ 1999-01-15 11:58 ` Bruce Stephens
1999-01-15 14:29 ` Geoff Wing
1 sibling, 0 replies; 8+ messages in thread
From: Bruce Stephens @ 1999-01-15 11:58 UTC (permalink / raw)
To: zsh-users
Andrew Gallagher <andrew.gallagher@earthling.net> writes:
> PROMPT='%? //%n@%B%m%b%//
> %l%1v%!> '
> RPROMPT='(%T, %w)'
> function precmd {
> echo -n "^[]0;//$USER@$HOSTNAME$PWD/ ($UNAME)^G"
> }
Or you can use print, of course. Here's mine:
# Set prompts
PROMPT=$(echo -n '%{\e[39;49m%}%m%#%(1v:+:)%{\e[39;49m%} ')
RPROMPT=$(echo -n ' %{\e[32;40m%}%~%{\e[39;49m%}')
precmd() {
print -Pn '\e]0;%n@%m:%~\a'
if jobs % >& /dev/null; then
psvar=("")
else
psvar=()
fi
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Xterm title changing prompt problem: HELP!
1999-01-15 11:48 ` Andrew Gallagher
1999-01-15 11:58 ` Bruce Stephens
@ 1999-01-15 14:29 ` Geoff Wing
1999-01-15 15:41 ` Andrew Gallagher
1 sibling, 1 reply; 8+ messages in thread
From: Geoff Wing @ 1999-01-15 14:29 UTC (permalink / raw)
To: zsh-users
Andrew Gallagher <andrew.gallagher@earthling.net> typed:
:Geoff Wing wrote:
:Or alternatively, take the escape sequence out of PROMPT and "echo -n" it
:from inside the precmd() function ... here is my version:
:
:The advantage of this is that it doesn't mess up non-xterm terminals so
:much (where the escape sequence will not be recognised and thus _will_
:shift the cursor). PROMPT will overwrite the "echo -n"ed line whether it
:is printed or not (so long as it is less than 80 chars).
No, PROMPT will only overwrite the echo output if you have PROMPT_CR
option set. It is set by default, so this only applies to people who
have done ``setopt nopromptcr'' (or ``unsetopt promptcr'') either
interactively or via startup files.
Regards,
--
Geoff Wing <gcw@pobox.com> Mobile : 0412 162 441
Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Xterm title changing prompt problem: HELP!
1999-01-15 14:29 ` Geoff Wing
@ 1999-01-15 15:41 ` Andrew Gallagher
1999-01-15 17:05 ` Geoff Wing
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Gallagher @ 1999-01-15 15:41 UTC (permalink / raw)
To: zsh-users
Geoff Wing wrote:
> Andrew Gallagher <andrew.gallagher@earthling.net> typed:
> PROMPT will overwrite the "echo -n"ed line whether it
> :is printed or not (so long as it is less than 80 chars).
>
> No, PROMPT will only overwrite the echo output if you have PROMPT_CR
> option set. It is set by default, so this only applies to people who
> have done ``setopt nopromptcr'' (or ``unsetopt promptcr'') either
> interactively or via startup files.
>
Good point, but surely you mean that it _doesn't_ apply to those who have
"setopt nopromptcr" ...?
foo> setopt nopromptcr (15:38, Fri
15)
foo> echo -n "ssssss" (15:39, Fri
15)
ssssssfoo> (15:39,
Fri 15)
foo> setopt promptcr (15:39, Fri
15)
foo> echo -n "ssssss" (15:39, Fri
15)
foo> (15:39, Fri
15)
--
Andrew Gallagher
http://members.tripod.com/~AndrewGallagher/id.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Xterm title changing prompt problem: HELP!
1999-01-15 15:41 ` Andrew Gallagher
@ 1999-01-15 17:05 ` Geoff Wing
1999-01-18 10:45 ` Andrew Gallagher
0 siblings, 1 reply; 8+ messages in thread
From: Geoff Wing @ 1999-01-15 17:05 UTC (permalink / raw)
To: zsh-users
Andrew Gallagher <andrew.gallagher@earthling.net> typed:
:Geoff Wing wrote:
:> Andrew Gallagher <andrew.gallagher@earthling.net> typed:
:> PROMPT will overwrite the "echo -n"ed line whether it
:> :is printed or not (so long as it is less than 80 chars).
:> No, PROMPT will only overwrite the echo output if you have PROMPT_CR
:> option set. It is set by default, so this only applies to people who
:> have done ``setopt nopromptcr'' (or ``unsetopt promptcr'') either
:> interactively or via startup files.
:Good point, but surely you mean that it _doesn't_ apply to those who have
:"setopt nopromptcr" ...?
Ah, sorry, when I said "this only applies ..." I meant along the lines of
"the only people who need take notice of this ..."
Regards,
--
Geoff Wing <gcw@pobox.com> Mobile : 0412 162 441
Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Xterm title changing prompt problem: HELP!
1999-01-15 17:05 ` Geoff Wing
@ 1999-01-18 10:45 ` Andrew Gallagher
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Gallagher @ 1999-01-18 10:45 UTC (permalink / raw)
To: zsh-users
Geoff Wing wrote:
> Andrew Gallagher <andrew.gallagher@earthling.net> typed:
> :Geoff Wing wrote:
> :> Andrew Gallagher <andrew.gallagher@earthling.net> typed:
> :> PROMPT will overwrite the "echo -n"ed line whether it
> :> :is printed or not (so long as it is less than 80 chars).
> :> No, PROMPT will only overwrite the echo output if you have PROMPT_CR
> :> option set. It is set by default, so this only applies to people who
> :> have done ``setopt nopromptcr'' (or ``unsetopt promptcr'') either
> :> interactively or via startup files.
> :Good point, but surely you mean that it _doesn't_ apply to those who have
> :"setopt nopromptcr" ...?
>
> Ah, sorry, when I said "this only applies ..." I meant along the lines of
> "the only people who need take notice of this ..."
>
I see what you mean now.
To get around this if you have done "setopt nopromptcr", you just tack the ^M
character onto the end of the "echo -n"ed string manually... et voila.
--
Andrew Gallagher
http://members.tripod.com/~AndrewGallagher/id.html
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~1999-01-18 10:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-14 22:17 Xterm title changing prompt problem: HELP! Shawn Leas
1999-01-14 23:25 ` Geoff Wing
1999-01-15 11:48 ` Andrew Gallagher
1999-01-15 11:58 ` Bruce Stephens
1999-01-15 14:29 ` Geoff Wing
1999-01-15 15:41 ` Andrew Gallagher
1999-01-15 17:05 ` Geoff Wing
1999-01-18 10:45 ` Andrew Gallagher
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).