You are not logged in.
Pages: 1
Topic closed
Hi all. I've just started having a fiddle with Zsh, and I am trying to copy the 2 line prompt I have in bash. But I have this little glitch where if I resize the terminal window while having a 2 (or more) line PS1, the prompt prints itself again half on top of the previous prompt. This happens with ones I have created and the included styles, adam2 elite etc.
It happens in urxvt, and in xterm, in awesomeWM and in compiz. Quite a minor issue, but it's rather annoying in awesomeWM when every terminal i open gets resized instantly and shows a mangled prompt.
What my prompt looks like:
┌─[pseup][~]
└─╼
What I get after a resize:
┌─[pseup][~]
┌─[pseup][~]
└─╼
My PS1 lines:
Bash:
PS1="┌─[\[\e[32;1m\]\u\[\e[0m\]][\[\e[34;1m\]\w\[\e[0m\]]\n└─╼ "
Zsh: (I've tried many ways of writing it, syntax so far hasn't affected it)
PS1="$(print '┌─[\e[32;1m%n\e[0m][\e[34;1m%~\e[0m]
└─╼ ')"
My ~/.zshrc contains nothing but the PS1 at this point.
Any ideas?
Last edited by pseup (2008-08-01 10:44:10)
Offline
I've always thought this was Intended Behaviour, however if someone has a solution I'd appreciate it as well.
Cthulhu For President!
Offline
This happens due to the way terminals react to resizing -- it doesn't have much to do with the shell you're running as such (although in bash, libreadline hates it.)
What happens when you resize the terminal is the contents try and respond to SIGWICH to say that the terminal has resized and the application therein should try and cater for that. Sometimes though it doesn't always happen; especially since most modern terminals don't respect the resize increment hints straight out the box.
If you type into any terminal:
echo $COLUMNS
echo $LINES
You'll see how wide and tall that window is with respect to the number of columns. However you can, sometimes resize your terminal to not exactly the same size -- which cuts out the expected display sometimes.
In your case you can:
reset && eval $(resize)
And that might be enough to help you.
HTH,
-- Thomas Adam
Last edited by ThomasAdam (2008-06-15 12:39:36)
Offline
Well, I had given up on this for quite some time, but have since found a work around for it, which I thought I would share.
I have started printing the first line of my prompt via the 'precmd()' function. Which does not appear to be reprinted when a re-size occurs.
This:
PROMPT="┌─[%{$fg[blue]%}%~%{$reset_color%}]
└─╼ "
Becomes:
precmd() { print -rP "┌─[%{$fg[blue]%}%~%{$reset_color%}]" }
PROMPT="└─╼ "
So now when I re-size only the '2nd' line of my prompt gets redrawn and it stays looking as it should.
Last edited by pseup (2008-08-01 11:02:26)
Offline
thanks for this ^
This thread is more than 2 years old. Please read our forum etiquettes about necroposting.
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Pages: 1
Topic closed