Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Constantly updated clock in prompt
- X-seq: zsh-users 18212
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Constantly updated clock in prompt
- Date: Mon, 09 Dec 2013 23:03:13 -0800
- In-reply-to: <CAEXBo6j4i=LtwV4FFByXgk--6Mmg1+1VpC=+H4 =YwTtFHP9wQ@mail.gmail.com>Comments: In reply to Samuel Laverdière <sam113101@gmail.com> "Constantly updated clock in prompt" (Dec 10, 1:10am)
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAEXBo6j4i=LtwV4FFByXgk--6Mmg1+1VpC=+H4_=YwTtFHP9wQ@mail.gmail.com>
On Dec 10, 1:10am, Samuel Laverdière wrote:
}
} I found a way to update the time in my prompt, but it breaks the completion
} menu (items in the menu become invisible). I found the solution on the
} Internet, so I know other people are looking for the same thing (updated
} time in prompt), but I can't believe they all learn to live with the bugs I
} have to deal with. Does it happen to anyone else? Is there a way to avoid
} it?
The menu-select widget isn't prepared to have its display interrupted by
reset-prompt (menu-select is in the separate zsh/complist module, and
IIRC reset-prompt was added after that module was written).
I keep the time in the window title bar instead of the prompt, and update
it with
print -nP "%{$top${*:-%m.%l:%2c - %t}$back%}"
(where $top and $back are the terminal-specific control codes update the
title bar).
You could easily do this with, say, the upper right corner of the screen
instead of the title bar.
(In more detail, I update the title bar in my precmd hook, and set the
initial TMOUT to 10 minutes so the title bar only starts updating itself
when I've been idle for a while.)
Other suggestions:
Create TRAPALRM before you assign TMOUT, or you're asking for a race to
occur where the signal arrives before it is trapped.
If you're only tracking time to the minute (%T), use TMOUT=10 so there
are fewer interrupts. Or to be really minimalist:
zmodload zsh/datetime
TRAPALARM() {
print -nP "%{$top${*:-%m.%l:%2c - %t}$back%}" # or whatever
TMOUT=$(( EPOCHSECONDS % 60 ))
}
TRAPALRM
One wakeup per minute, exactly on the minute!
Aside for zsh-workers:
With
TRAPALRM() { zle reset-prompt; zle redisplay }
(or pretty much any zle thing after reset-prompt) I get:
Src/Zle/zle_thingy.c:660: line metafied
However, that does NOT happen if I do
TRAPALRM() { zle -I; zle reset-prompt; zle redisplay }
Whatever that bug is, has no effect on the menu-select redraw problem.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author