You are not logged in.

#1 2008-06-15 02:56:02

pseup
Member
Registered: 2008-06-06
Posts: 103

[Solved] Zsh prompt reprint when resizing terminal.

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

#2 2008-06-15 11:58:18

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: [Solved] Zsh prompt reprint when resizing terminal.

I've always thought this was Intended Behaviour, however if someone has a solution I'd appreciate it as well.


Cthulhu For President!

Offline

#3 2008-06-15 12:39:21

ThomasAdam
Member
From: Southampton, England
Registered: 2005-10-26
Posts: 148

Re: [Solved] Zsh prompt reprint when resizing terminal.

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

#4 2008-08-01 10:43:50

pseup
Member
Registered: 2008-06-06
Posts: 103

Re: [Solved] Zsh prompt reprint when resizing terminal.

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

#5 2010-08-19 10:55:43

Jimi
Member
From: Brooklyn, NY
Registered: 2009-09-25
Posts: 125
Website

Re: [Solved] Zsh prompt reprint when resizing terminal.

thanks for this ^

Offline

#6 2010-08-19 18:53:52

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [Solved] Zsh prompt reprint when resizing terminal.

Jimi wrote:

thanks for this ^

This thread is more than 2 years old. Please read our forum etiquettes about necroposting.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

Board footer

Powered by FluxBB