zsh-users
 help / color / mirror / code / Atom feed
* prompts with newlines get printed twice
@ 2011-09-24  2:52 Jorge Israel Peña
  2011-09-24 18:24 ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-24  2:52 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1094 bytes --]

Hey guys. I'm new to zsh and I have been playing with getting my prompt set
up nicely.

The problem I'm encountering is that when I create a newline in the prompt,
the prompt gets printed twice when I open the terminal.

Example:

In ~/.zshrc

PROMPT='%n @ %m
$ '

results in:

Last login: Fri Sep 23 19:13:38 on ttys000
user at host
user at host
$

This happens without fail whenever I open the Terminal application,
regardless of the amount of tabs. However, once the application is running,
if I open a new window or tab, this does not happen and the prompt is
correctly displayed only once. What intrigues me is that it only prints the
top part twice but not the '$' part. Any guesses as to why this might be
happening? I have spent hours on it to no avail, so I would really
appreciate any help.

I'm on Mac OS X 10.7 Lion.
zsh version is 4.3.11, what came with Lion.
I also experience this with 4.3.12 that I installed with brew.
This happens even if I change the Terminal to run /bin/zsh instead of
/usr/bin/login

Thanks.

-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-24  2:52 prompts with newlines get printed twice Jorge Israel Peña
@ 2011-09-24 18:24 ` Bart Schaefer
  2011-09-24 18:31   ` Mikael Magnusson
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2011-09-24 18:24 UTC (permalink / raw)
  To: zsh-users

On Sep 23,  7:52pm, Jorge Israel Pena wrote:
}
} The problem I'm encountering is that when I create a newline in the prompt,
} the prompt gets printed twice when I open the terminal.

We've been wrestling with this one for a while.  The trouble seems to be
that Terminal sends extra WINCH (window size change) signals to the shell,
which causes it to reprint the prompt.

Zsh doesn't attempt to perform a cursor-up before printing the prompt, as
for command line editing purposes it only keeps track of the appearance of
the final line.


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

* Re: prompts with newlines get printed twice
  2011-09-24 18:24 ` Bart Schaefer
@ 2011-09-24 18:31   ` Mikael Magnusson
  2011-09-24 23:24     ` Jorge Israel Peña
  0 siblings, 1 reply; 12+ messages in thread
From: Mikael Magnusson @ 2011-09-24 18:31 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

On 24 September 2011 20:24, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Sep 23,  7:52pm, Jorge Israel Pena wrote:
> }
> } The problem I'm encountering is that when I create a newline in the prompt,
> } the prompt gets printed twice when I open the terminal.
>
> We've been wrestling with this one for a while.  The trouble seems to be
> that Terminal sends extra WINCH (window size change) signals to the shell,
> which causes it to reprint the prompt.
>
> Zsh doesn't attempt to perform a cursor-up before printing the prompt, as
> for command line editing purposes it only keeps track of the appearance of
> the final line.

I'm seeing some strange behaviour here, when I resize after setting
PS1='%D{%s} hello
there '
I do get the first line twice, but subsequent resizes properly redraws
both lines in place, updating the time too. Pressing enter then causes
the next resize to double the first line and then subsequent ones work
again.

-- 
Mikael Magnusson


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

* Re: prompts with newlines get printed twice
  2011-09-24 18:31   ` Mikael Magnusson
@ 2011-09-24 23:24     ` Jorge Israel Peña
  2011-09-25  0:14       ` Jorge Israel Peña
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-24 23:24 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Bart Schaefer, zsh-users

[-- Attachment #1: Type: text/plain, Size: 2129 bytes --]

Thanks for the replies. At least I'm glad to know it's not just me, I spent
a few hours on this wondering if it was something I could have screwed up.

So are there any known workarounds? Or is this something that would have to
be fixed in zsh itself?

I found this [ http://www.df.lth.se/~arno/kod/prompt/uberprompt-sh ] which
has a comment near the end:

> Mac OS X Terminal.app and IRIX xwsh seems to send repetetive WINCH to
solaris boxen

Then it includes some code, but I don't know if it's a workaround to this
problem in particular (it seems like it is, includes some sort of trapping
of the WINCHes), much less how to make use of that code. I just figured I'd
post it in case some of you guys could make sense of it (that section in
particular is pretty short).

Hopefully it could provide some information that we can use to fix this, or
at least provide a workaround. The two prompts that pop up are pretty
jarring, somehow.

On Sat, Sep 24, 2011 at 11:31 AM, Mikael Magnusson <mikachu@gmail.com>wrote:

> On 24 September 2011 20:24, Bart Schaefer <schaefer@brasslantern.com>
> wrote:
> > On Sep 23,  7:52pm, Jorge Israel Pena wrote:
> > }
> > } The problem I'm encountering is that when I create a newline in the
> prompt,
> > } the prompt gets printed twice when I open the terminal.
> >
> > We've been wrestling with this one for a while.  The trouble seems to be
> > that Terminal sends extra WINCH (window size change) signals to the
> shell,
> > which causes it to reprint the prompt.
> >
> > Zsh doesn't attempt to perform a cursor-up before printing the prompt, as
> > for command line editing purposes it only keeps track of the appearance
> of
> > the final line.
>
> I'm seeing some strange behaviour here, when I resize after setting
> PS1='%D{%s} hello
> there '
> I do get the first line twice, but subsequent resizes properly redraws
> both lines in place, updating the time too. Pressing enter then causes
> the next resize to double the first line and then subsequent ones work
> again.
>
> --
> Mikael Magnusson
>



-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-24 23:24     ` Jorge Israel Peña
@ 2011-09-25  0:14       ` Jorge Israel Peña
  2011-09-25 22:13         ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-25  0:14 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Bart Schaefer, zsh-users

[-- Attachment #1: Type: text/plain, Size: 2998 bytes --]

Hey guys. I have extracted what I felt were the relevant parts from my
previously posted link. Like I said, I am no zsh expert (In fact I'm
completely new to it) so I don't know if this is right or if there are more
efficient, better ways of doing this.

Source: https://gist.github.com/1240023

I tested it various times and it seems to be working perfectly.

What the script seems to do is wrap the PROMPT or PS1 directive in a
function, and then does a `trap func WINCH` on it. Also call the function in
precmd so it happens all the time?

Like I said, it seems like it works, but is this the best way of solving
this? If it is, then I'm glad I've found a way to solve this :)

2011/9/24 Jorge Israel Peña <jorgepblank@gmail.com>

> Thanks for the replies. At least I'm glad to know it's not just me, I spent
> a few hours on this wondering if it was something I could have screwed up.
>
> So are there any known workarounds? Or is this something that would have to
> be fixed in zsh itself?
>
> I found this [ http://www.df.lth.se/~arno/kod/prompt/uberprompt-sh ] which
> has a comment near the end:
>
> > Mac OS X Terminal.app and IRIX xwsh seems to send repetetive WINCH to
> solaris boxen
>
> Then it includes some code, but I don't know if it's a workaround to this
> problem in particular (it seems like it is, includes some sort of trapping
> of the WINCHes), much less how to make use of that code. I just figured I'd
> post it in case some of you guys could make sense of it (that section in
> particular is pretty short).
>
> Hopefully it could provide some information that we can use to fix this, or
> at least provide a workaround. The two prompts that pop up are pretty
> jarring, somehow.
>
> On Sat, Sep 24, 2011 at 11:31 AM, Mikael Magnusson <mikachu@gmail.com>wrote:
>
>> On 24 September 2011 20:24, Bart Schaefer <schaefer@brasslantern.com>
>> wrote:
>> > On Sep 23,  7:52pm, Jorge Israel Pena wrote:
>> > }
>> > } The problem I'm encountering is that when I create a newline in the
>> prompt,
>> > } the prompt gets printed twice when I open the terminal.
>> >
>> > We've been wrestling with this one for a while.  The trouble seems to be
>> > that Terminal sends extra WINCH (window size change) signals to the
>> shell,
>> > which causes it to reprint the prompt.
>> >
>> > Zsh doesn't attempt to perform a cursor-up before printing the prompt,
>> as
>> > for command line editing purposes it only keeps track of the appearance
>> of
>> > the final line.
>>
>> I'm seeing some strange behaviour here, when I resize after setting
>> PS1='%D{%s} hello
>> there '
>> I do get the first line twice, but subsequent resizes properly redraws
>> both lines in place, updating the time too. Pressing enter then causes
>> the next resize to double the first line and then subsequent ones work
>> again.
>>
>> --
>> Mikael Magnusson
>>
>
>
>
> --
> - Jorge Israel Peña
>



-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-25  0:14       ` Jorge Israel Peña
@ 2011-09-25 22:13         ` Bart Schaefer
  2011-09-25 23:31           ` Jorge Israel Peña
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2011-09-25 22:13 UTC (permalink / raw)
  To: zsh-users

On Sep 24,  4:24pm, Jorge Israel Pena wrote:
}
} So are there any known workarounds? Or is this something that would
} have to be fixed in zsh itself?

Until a few minutes ago I'd have said it was something that needed to
be fixed in Terminal, but I may have found a zsh bug that's behind it
all.  I've sent a possible fix to zsh-workers for discussion.

On Sep 24,  5:14pm, Jorge Israel Pena wrote:
} 
} Hey guys. I have extracted what I felt were the relevant parts from my
} previously posted link. Like I said, I am no zsh expert (In fact I'm
} completely new to it) so I don't know if this is right or if there are
} more efficient, better ways of doing this.
} 
} Source: https://gist.github.com/1240023
} 
} I tested it various times and it seems to be working perfectly.

I don't find any evidence that this helps except possibly by waiting to 
change the prompt until the first time the WINCH is received, which
would avoid the startup-time double prompt.  I still get the prompt
printed multiple times if I later resize the window.

However,

    trap 'tput cuu1' WINCH

(that is, move up one line on each WINCH signal) might work around it
for you.  If your prompt has more than two lines, you'll need to move
up one less than the number of lines in the prompt.


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

* Re: prompts with newlines get printed twice
  2011-09-25 22:13         ` Bart Schaefer
@ 2011-09-25 23:31           ` Jorge Israel Peña
  2011-09-26  4:22             ` Jorge Israel Peña
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-25 23:31 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2021 bytes --]

Thanks for your time Bart.

I have tested your workaround and it does seem to work! This seems better
because there is no need to wrap the prompt directive in a function or any
of that stuff.

I saw your post on the workers mailing list, thanks again for taking the
time to look into it. Hopefully now that you've brought attention to this it
could be discussed by people more knowledgeable with the zsh source and
perhaps even get it fixed.

For now I'm glad I have a workaround I can use in .zshrc at least :)

Thanks again!

On Sun, Sep 25, 2011 at 3:13 PM, Bart Schaefer <schaefer@brasslantern.com>wrote:

> On Sep 24,  4:24pm, Jorge Israel Pena wrote:
> }
> } So are there any known workarounds? Or is this something that would
> } have to be fixed in zsh itself?
>
> Until a few minutes ago I'd have said it was something that needed to
> be fixed in Terminal, but I may have found a zsh bug that's behind it
> all.  I've sent a possible fix to zsh-workers for discussion.
>
> On Sep 24,  5:14pm, Jorge Israel Pena wrote:
> }
> } Hey guys. I have extracted what I felt were the relevant parts from my
> } previously posted link. Like I said, I am no zsh expert (In fact I'm
> } completely new to it) so I don't know if this is right or if there are
> } more efficient, better ways of doing this.
> }
> } Source: https://gist.github.com/1240023
> }
> } I tested it various times and it seems to be working perfectly.
>
> I don't find any evidence that this helps except possibly by waiting to
> change the prompt until the first time the WINCH is received, which
> would avoid the startup-time double prompt.  I still get the prompt
> printed multiple times if I later resize the window.
>
> However,
>
>    trap 'tput cuu1' WINCH
>
> (that is, move up one line on each WINCH signal) might work around it
> for you.  If your prompt has more than two lines, you'll need to move
> up one less than the number of lines in the prompt.
>



-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-25 23:31           ` Jorge Israel Peña
@ 2011-09-26  4:22             ` Jorge Israel Peña
  2011-09-26  4:29               ` Jorge Israel Peña
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-26  4:22 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2747 bytes --]

Hey Bart, you said move up one less line than the amount you have. So I was
playing around with the prompt by making it three lines (so that there's an
empty line after the previous command's output, etc.) and the way I did it
is:

trap 'tput cuu1 tput cuu1' WINCH

But I don't think this is the correct way? When I resize the terminal
horizontally with this, the prompt keeps moving down by itself, but this
doesn't happen when it's just one line and there is only one 'tput cuu1', so
I have a feeling I'm doing it wrong. Would appreciate any comments.

2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>

> Thanks for your time Bart.
>
> I have tested your workaround and it does seem to work! This seems better
> because there is no need to wrap the prompt directive in a function or any
> of that stuff.
>
> I saw your post on the workers mailing list, thanks again for taking the
> time to look into it. Hopefully now that you've brought attention to this it
> could be discussed by people more knowledgeable with the zsh source and
> perhaps even get it fixed.
>
> For now I'm glad I have a workaround I can use in .zshrc at least :)
>
> Thanks again!
>
> On Sun, Sep 25, 2011 at 3:13 PM, Bart Schaefer <schaefer@brasslantern.com>wrote:
>
>> On Sep 24,  4:24pm, Jorge Israel Pena wrote:
>> }
>> } So are there any known workarounds? Or is this something that would
>> } have to be fixed in zsh itself?
>>
>> Until a few minutes ago I'd have said it was something that needed to
>> be fixed in Terminal, but I may have found a zsh bug that's behind it
>> all.  I've sent a possible fix to zsh-workers for discussion.
>>
>> On Sep 24,  5:14pm, Jorge Israel Pena wrote:
>> }
>> } Hey guys. I have extracted what I felt were the relevant parts from my
>> } previously posted link. Like I said, I am no zsh expert (In fact I'm
>> } completely new to it) so I don't know if this is right or if there are
>> } more efficient, better ways of doing this.
>> }
>> } Source: https://gist.github.com/1240023
>> }
>> } I tested it various times and it seems to be working perfectly.
>>
>> I don't find any evidence that this helps except possibly by waiting to
>> change the prompt until the first time the WINCH is received, which
>> would avoid the startup-time double prompt.  I still get the prompt
>> printed multiple times if I later resize the window.
>>
>> However,
>>
>>    trap 'tput cuu1' WINCH
>>
>> (that is, move up one line on each WINCH signal) might work around it
>> for you.  If your prompt has more than two lines, you'll need to move
>> up one less than the number of lines in the prompt.
>>
>
>
>
> --
> - Jorge Israel Peña
>



-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-26  4:22             ` Jorge Israel Peña
@ 2011-09-26  4:29               ` Jorge Israel Peña
  2011-09-27  1:42                 ` Jorge Israel Peña
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-26  4:29 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 3227 bytes --]

Actually, `man terminfo` showed me the `cuu` command which accepts a
parameter referring to the number of lines to move up. Changing the
aforementioned line to:

trap 'tput cuu 2' WINCH

seems to work consistently and does not make the prompt move down when
resizing the terminal :)

2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>

> Hey Bart, you said move up one less line than the amount you have. So I was
> playing around with the prompt by making it three lines (so that there's an
> empty line after the previous command's output, etc.) and the way I did it
> is:
>
> trap 'tput cuu1 tput cuu1' WINCH
>
> But I don't think this is the correct way? When I resize the terminal
> horizontally with this, the prompt keeps moving down by itself, but this
> doesn't happen when it's just one line and there is only one 'tput cuu1', so
> I have a feeling I'm doing it wrong. Would appreciate any comments.
>
>
> 2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>
>
>> Thanks for your time Bart.
>>
>> I have tested your workaround and it does seem to work! This seems better
>> because there is no need to wrap the prompt directive in a function or any
>> of that stuff.
>>
>> I saw your post on the workers mailing list, thanks again for taking the
>> time to look into it. Hopefully now that you've brought attention to this it
>> could be discussed by people more knowledgeable with the zsh source and
>> perhaps even get it fixed.
>>
>> For now I'm glad I have a workaround I can use in .zshrc at least :)
>>
>> Thanks again!
>>
>> On Sun, Sep 25, 2011 at 3:13 PM, Bart Schaefer <schaefer@brasslantern.com
>> > wrote:
>>
>>> On Sep 24,  4:24pm, Jorge Israel Pena wrote:
>>> }
>>> } So are there any known workarounds? Or is this something that would
>>> } have to be fixed in zsh itself?
>>>
>>> Until a few minutes ago I'd have said it was something that needed to
>>> be fixed in Terminal, but I may have found a zsh bug that's behind it
>>> all.  I've sent a possible fix to zsh-workers for discussion.
>>>
>>> On Sep 24,  5:14pm, Jorge Israel Pena wrote:
>>> }
>>> } Hey guys. I have extracted what I felt were the relevant parts from my
>>> } previously posted link. Like I said, I am no zsh expert (In fact I'm
>>> } completely new to it) so I don't know if this is right or if there are
>>> } more efficient, better ways of doing this.
>>> }
>>> } Source: https://gist.github.com/1240023
>>> }
>>> } I tested it various times and it seems to be working perfectly.
>>>
>>> I don't find any evidence that this helps except possibly by waiting to
>>> change the prompt until the first time the WINCH is received, which
>>> would avoid the startup-time double prompt.  I still get the prompt
>>> printed multiple times if I later resize the window.
>>>
>>> However,
>>>
>>>    trap 'tput cuu1' WINCH
>>>
>>> (that is, move up one line on each WINCH signal) might work around it
>>> for you.  If your prompt has more than two lines, you'll need to move
>>> up one less than the number of lines in the prompt.
>>>
>>
>>
>>
>> --
>> - Jorge Israel Peña
>>
>
>
>
> --
> - Jorge Israel Peña
>



-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-26  4:29               ` Jorge Israel Peña
@ 2011-09-27  1:42                 ` Jorge Israel Peña
  2011-09-27  1:48                   ` Jorge Israel Peña
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-27  1:42 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 3661 bytes --]

Just wanted to follow up. It seems like multiline prompts cause zsh to exit
([Process Completed]) when I do tab completion more than once:

cd ~/.vim<TAB><TAB><TAB>[Process Completed]

I have made sure this is what's causing it.

2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>

> Actually, `man terminfo` showed me the `cuu` command which accepts a
> parameter referring to the number of lines to move up. Changing the
> aforementioned line to:
>
> trap 'tput cuu 2' WINCH
>
> seems to work consistently and does not make the prompt move down when
> resizing the terminal :)
>
>
> 2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>
>
>> Hey Bart, you said move up one less line than the amount you have. So I
>> was playing around with the prompt by making it three lines (so that there's
>> an empty line after the previous command's output, etc.) and the way I did
>> it is:
>>
>> trap 'tput cuu1 tput cuu1' WINCH
>>
>> But I don't think this is the correct way? When I resize the terminal
>> horizontally with this, the prompt keeps moving down by itself, but this
>> doesn't happen when it's just one line and there is only one 'tput cuu1', so
>> I have a feeling I'm doing it wrong. Would appreciate any comments.
>>
>>
>> 2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>
>>
>>> Thanks for your time Bart.
>>>
>>> I have tested your workaround and it does seem to work! This seems better
>>> because there is no need to wrap the prompt directive in a function or any
>>> of that stuff.
>>>
>>> I saw your post on the workers mailing list, thanks again for taking the
>>> time to look into it. Hopefully now that you've brought attention to this it
>>> could be discussed by people more knowledgeable with the zsh source and
>>> perhaps even get it fixed.
>>>
>>> For now I'm glad I have a workaround I can use in .zshrc at least :)
>>>
>>> Thanks again!
>>>
>>> On Sun, Sep 25, 2011 at 3:13 PM, Bart Schaefer <
>>> schaefer@brasslantern.com> wrote:
>>>
>>>> On Sep 24,  4:24pm, Jorge Israel Pena wrote:
>>>> }
>>>> } So are there any known workarounds? Or is this something that would
>>>> } have to be fixed in zsh itself?
>>>>
>>>> Until a few minutes ago I'd have said it was something that needed to
>>>> be fixed in Terminal, but I may have found a zsh bug that's behind it
>>>> all.  I've sent a possible fix to zsh-workers for discussion.
>>>>
>>>> On Sep 24,  5:14pm, Jorge Israel Pena wrote:
>>>> }
>>>> } Hey guys. I have extracted what I felt were the relevant parts from my
>>>> } previously posted link. Like I said, I am no zsh expert (In fact I'm
>>>> } completely new to it) so I don't know if this is right or if there are
>>>> } more efficient, better ways of doing this.
>>>> }
>>>> } Source: https://gist.github.com/1240023
>>>> }
>>>> } I tested it various times and it seems to be working perfectly.
>>>>
>>>> I don't find any evidence that this helps except possibly by waiting to
>>>> change the prompt until the first time the WINCH is received, which
>>>> would avoid the startup-time double prompt.  I still get the prompt
>>>> printed multiple times if I later resize the window.
>>>>
>>>> However,
>>>>
>>>>    trap 'tput cuu1' WINCH
>>>>
>>>> (that is, move up one line on each WINCH signal) might work around it
>>>> for you.  If your prompt has more than two lines, you'll need to move
>>>> up one less than the number of lines in the prompt.
>>>>
>>>
>>>
>>>
>>> --
>>> - Jorge Israel Peña
>>>
>>
>>
>>
>> --
>> - Jorge Israel Peña
>>
>
>
>
> --
> - Jorge Israel Peña
>



-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-27  1:42                 ` Jorge Israel Peña
@ 2011-09-27  1:48                   ` Jorge Israel Peña
  2011-09-27 14:32                     ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Jorge Israel Peña @ 2011-09-27  1:48 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 4114 bytes --]

I think it's because after the third tab, the directory gets reprinted and
each subsequent TAB makes it cycle through possible candidates. This
redrawing I imagine is somehow interfering with the trap cuu 2 WINCH
workaround.

2011/9/26 Jorge Israel Peña <jorgepblank@gmail.com>

> Just wanted to follow up. It seems like multiline prompts cause zsh to exit
> ([Process Completed]) when I do tab completion more than once:
>
> cd ~/.vim<TAB><TAB><TAB>[Process Completed]
>
> I have made sure this is what's causing it.
>
> 2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>
>
>> Actually, `man terminfo` showed me the `cuu` command which accepts a
>> parameter referring to the number of lines to move up. Changing the
>> aforementioned line to:
>>
>> trap 'tput cuu 2' WINCH
>>
>> seems to work consistently and does not make the prompt move down when
>> resizing the terminal :)
>>
>>
>> 2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>
>>
>>> Hey Bart, you said move up one less line than the amount you have. So I
>>> was playing around with the prompt by making it three lines (so that there's
>>> an empty line after the previous command's output, etc.) and the way I did
>>> it is:
>>>
>>> trap 'tput cuu1 tput cuu1' WINCH
>>>
>>> But I don't think this is the correct way? When I resize the terminal
>>> horizontally with this, the prompt keeps moving down by itself, but this
>>> doesn't happen when it's just one line and there is only one 'tput cuu1', so
>>> I have a feeling I'm doing it wrong. Would appreciate any comments.
>>>
>>>
>>> 2011/9/25 Jorge Israel Peña <jorgepblank@gmail.com>
>>>
>>>> Thanks for your time Bart.
>>>>
>>>> I have tested your workaround and it does seem to work! This seems
>>>> better because there is no need to wrap the prompt directive in a function
>>>> or any of that stuff.
>>>>
>>>> I saw your post on the workers mailing list, thanks again for taking the
>>>> time to look into it. Hopefully now that you've brought attention to this it
>>>> could be discussed by people more knowledgeable with the zsh source and
>>>> perhaps even get it fixed.
>>>>
>>>> For now I'm glad I have a workaround I can use in .zshrc at least :)
>>>>
>>>> Thanks again!
>>>>
>>>> On Sun, Sep 25, 2011 at 3:13 PM, Bart Schaefer <
>>>> schaefer@brasslantern.com> wrote:
>>>>
>>>>> On Sep 24,  4:24pm, Jorge Israel Pena wrote:
>>>>> }
>>>>> } So are there any known workarounds? Or is this something that would
>>>>> } have to be fixed in zsh itself?
>>>>>
>>>>> Until a few minutes ago I'd have said it was something that needed to
>>>>> be fixed in Terminal, but I may have found a zsh bug that's behind it
>>>>> all.  I've sent a possible fix to zsh-workers for discussion.
>>>>>
>>>>> On Sep 24,  5:14pm, Jorge Israel Pena wrote:
>>>>> }
>>>>> } Hey guys. I have extracted what I felt were the relevant parts from
>>>>> my
>>>>> } previously posted link. Like I said, I am no zsh expert (In fact I'm
>>>>> } completely new to it) so I don't know if this is right or if there
>>>>> are
>>>>> } more efficient, better ways of doing this.
>>>>> }
>>>>> } Source: https://gist.github.com/1240023
>>>>> }
>>>>> } I tested it various times and it seems to be working perfectly.
>>>>>
>>>>> I don't find any evidence that this helps except possibly by waiting to
>>>>> change the prompt until the first time the WINCH is received, which
>>>>> would avoid the startup-time double prompt.  I still get the prompt
>>>>> printed multiple times if I later resize the window.
>>>>>
>>>>> However,
>>>>>
>>>>>    trap 'tput cuu1' WINCH
>>>>>
>>>>> (that is, move up one line on each WINCH signal) might work around it
>>>>> for you.  If your prompt has more than two lines, you'll need to move
>>>>> up one less than the number of lines in the prompt.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> - Jorge Israel Peña
>>>>
>>>
>>>
>>>
>>> --
>>> - Jorge Israel Peña
>>>
>>
>>
>>
>> --
>> - Jorge Israel Peña
>>
>
>
>
> --
> - Jorge Israel Peña
>



-- 
- Jorge Israel Peña

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

* Re: prompts with newlines get printed twice
  2011-09-27  1:48                   ` Jorge Israel Peña
@ 2011-09-27 14:32                     ` Bart Schaefer
  0 siblings, 0 replies; 12+ messages in thread
From: Bart Schaefer @ 2011-09-27 14:32 UTC (permalink / raw)
  To: zsh-users

On Sep 26,  6:42pm, Jorge Israel Pena wrote:
} 
} Just wanted to follow up. It seems like multiline prompts cause zsh to exit
} ([Process Completed]) when I do tab completion more than once:
} 
} cd ~/.vim<TAB><TAB><TAB>[Process Completed]

Sorry if you've mentioned this before, but could you be specific about
the version of zsh here?
 
} I have made sure this is what's causing it.

So what *exactly* is the difference in your configuration when it does
not happen vs. when it does?

On Sep 26,  6:48pm, Jorge Israel Pena wrote:
} 
} I think it's because after the third tab, the directory gets reprinted and
} each subsequent TAB makes it cycle through possible candidates. This
} redrawing I imagine is somehow interfering with the trap cuu 2 WINCH
} workaround.

Uneless your terminal size is changing this can't have anything to do
with the trap.  It's called only in the event of an external signal,
not every time the prompt is redrawn.


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

end of thread, other threads:[~2011-09-27 14:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-24  2:52 prompts with newlines get printed twice Jorge Israel Peña
2011-09-24 18:24 ` Bart Schaefer
2011-09-24 18:31   ` Mikael Magnusson
2011-09-24 23:24     ` Jorge Israel Peña
2011-09-25  0:14       ` Jorge Israel Peña
2011-09-25 22:13         ` Bart Schaefer
2011-09-25 23:31           ` Jorge Israel Peña
2011-09-26  4:22             ` Jorge Israel Peña
2011-09-26  4:29               ` Jorge Israel Peña
2011-09-27  1:42                 ` Jorge Israel Peña
2011-09-27  1:48                   ` Jorge Israel Peña
2011-09-27 14:32                     ` 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).