Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Add customizable `vcs` prompt theme (was Re: [RFC][PATCH] `newuser` prompt theme)

On Mon, Jun 21, 2021 at 12:14 AM Marlon Richert
<marlon.richert@xxxxxxxxx> wrote:
> On Thu, Jun 10, 2021 at 8:45 PM Roman Perepelitsa
> <roman.perepelitsa@xxxxxxxxx> wrote:
> >
> > I was expecting the readonly parameter at the top to print an error.
> >
> >   % readonly -gHA _prompt_vcs_ps1_default=()
> >   % readonly -gHA _prompt_vcs_ps1_default=()
> >   zsh: read-only variable: _prompt_vcs_ps1_default
> That doesn't actually happen, because prompt_vcs_setup gets redefined
> inside the first call to prompt_vcs_setup. $_prompt_vcs_ps1_default
> gets set only the first time you call prompt_vcs_setup.

I see. Makes sense.

> > It's also unclear to me whether this prompt supports clean
> > deinitialization and repeated initialization. Doesn't look like it.
> > Does it?
> You're supposed to use this prompt theme with prompinit's `prompt`
> function.

Yes, I realize that.

> If you do so, then deinitialization and repeated
> initialization is pretty much clean, as far as I can tell.
> Is there anything in particular that I should be checking?

It's not obvious to me that deinitialization will happen. Imagine what
would happen if another theme is enabled while there is a process
running in the background from your theme. Won't your theme change
prompt when the background process finishes?

By the way, would running `prompt -p` unintentionally enabled your theme?

> > I see that the code is sending SIGKILL now and not waiting for the
> > process to terminate. Both of these make me nervous. The code also
> > *looks like* it would work without monitor but it wouldn't (it would
> > result in unbounded background processes and zombies). What do you
> > think about not killing anything and ensuring that at most one
> > background process runs at once? This is what I do in my zsh theme and
> > it works well.
> That sounds great, but I have no idea how to do that. :) Can you give
> me some pointers?

Start a new process in precmd if none are running. If one is already
running, don't start a new process but remember that its results are
"dirty". When a background process completes, display its results if
they aren't marked dirty. If they are marked dirty, don't display the
results but start a new process instead.


Messages sorted by: Reverse Date, Date, Thread, Author