Closed romibi closed 9 months ago
@romibi the issue is that that z implementation doesn't set a priority when they create the prompt filter. If you use z.lua they do set this, and we can fetch their priority and adjust accordingly. Switch implementation or ask clink-zoxide
to also use and set the _ZL_CLINK_PROMPT_PRIORITY
variable.
@JanDeDobbeleer After quite a lot of reading up … I'm still not sure if you really can just blame clink-zoxide
… I think you should reopen the issue …
Looking at clink's prompt.lua not setting a priority equals to a priority of 999?
Ok, that is (compared to the used numbers I found on github) a bit a high number (low prio)…
oh-my-posh seems to use priority 1 if that _ZL_CLINK_PROMPT_PRIORITY
variable is not set.
Reading up further on that promptfilter functionality a filter can return a string and/or a boolean or nil. The string is used as a new prompt (and further filters) and the boolean defines if further filters should be processed.
For clink-zoxide
(and i think probably also for z.lua
) it shouldn't matter if it comes before or after oh-my-posh.
So why is it that oh-my-posh prevents that? I can't seem to find where the boolean false is coming from and i'm not too familiar with lua.
Also, if I understand the code in z.lua correctly, it doesn't SET the _ZL_CLINK_PROMPT_PRIORITY
variable but uses the value from it if it is set. So (i think) if you don't change/set it, oh-my-posh would still prevent z.lua from working (I haven't tested it).
and _ZL_
seems to be the prefix for z.lua's config environment variables. So I'm not sure if it would be correct to set that variable from clink-zoxide
.
So yea … I can just modify the clink-zoxide
script to use prio 0 (or some negative value) …
And maybe I'll make a PR to clink-zoxide
to make the prio configurable …
But I think oh-my-posh should be improved in this regard as well (allowing further filtering/configuratility separate from z.lua) …
@romibi let's ask someone who knows instead of theorizing over something we're not familiar with.
@chrisant996 care to shed some light on the situation?
The problem is in clink-zoxide.
It doesn't specify any priority. Which gives it an extremely low priority. In other words, there's a good chance it won't get to run at all. It should specify 0 or lower (negative).
For clink-zoxide (and i think probably also for z.lua) it shouldn't matter if it comes before or after oh-my-posh. So why is it that oh-my-posh prevents that? I can't seem to find where the boolean false is coming from and i'm not too familiar with lua.
No, that's incorrect. Oh-my-posh has to tell Clink to stop running other prompt filters. Otherwise starship or clink-flex-prompt or cmder-powerline or cmder's prompt filter or other personal custom prompt filters would also run, and then you'd get multiple prompts all showing at the same time, jumbled together in strange ways.
The bug is primarily in clink-zoxide, by not specifying a priority at all, and simultaneously expecting its prompt filter to be guaranteed to run.
And the bug is secondarily in the Clink documentation for Customizing the Prompt and clink.promptfilter(), for not calling out in more detail why scripts want to return false and stop further prompt filters from running, and the fact that stopping prompt filters from running ... means they don't run. Sorry, it didn't occur to me (or to Martin, apparently) that that needed to be emphasized.
Oh-my-posh shouldn't change what it's doing, nor its priority value. However, it could potentially be reasonable to add a way for a user to override its promptfilter priority (similar to how clink-zoxide provides a way).
z.lua has a similar problem as clink-zoxide, because its default priority is 99. Its default priority should be 0 or less.
… add a way for a user to override its promptfilter priority (similar to how clink-zoxide provides a way).
you mean z.lua.
Thank you for your explanation. I'll probably make a Pull Request to clink-zoxide for configurability. Locally I've already changed it in the lua to 0.
And personally, I'd recommend something like:
-999
through -50
for prompt filters that aren't actually providing a prompt string, and are instead intercepting when the prompt gets generated, for whatever reason.-25
through 0
for prompt filters that are willing to get skipped sometimes with certain extra-high priority prompt string generation that needs to conditionally sometimes happen earlier than 1
.1
through 25
for prompt filters that provide a prompt string that's meant to be the only prompt string.50
or greater for prompt filters that are meant to work together and concatenate together.In modern versions of Clink, clink.onbeginedit() is what both z.lua and clink-zoxide really want. But they're old enough that they predate the existence of clink.onbeginedit, and at the time clink.promptfilter was the only way. But 0 or negative was always the right priority to specify.
For
clink-zoxide
(and i think probably also forz.lua
) it shouldn't matter if it comes before or after oh-my-posh. So why is it that oh-my-posh prevents that? I can't seem to find where the boolean false is coming from and i'm not too familiar with lua.
It's coming from the right-side prompt filters:
and
This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.
Code of Conduct
What happened?
I'm not completely sure where the issue is (which tool/app) but I think its oh-my-posh.
I tried setting up clink with oh-my-posh and zoxide-clink.
Clink with oh-my-posh works fine. Clink with zoxide-clink works fine.
But as soon as both oh-my-posh as well as zoxide-clink are active zoxide-clink stopps working.
Debug output in the zoxide.lua made me realize that as soon as i have the oh-my-posh.lua the
clink.promptfilter():filter()
doesn't get called anymore, which is used by zoxide-clink to detect directory changes.So I'm not sure if the error is with clink or with oh-my-posh but the zoxide-clink script seems correct. See also: https://github.com/shunsambongi/clink-zoxide/issues/6 for a workaround in the meantime.
Theme
Theme? Shouldn't matter, but a modified version of powerlevel10k_rainbow
What OS are you seeing the problem on?
Windows
Which shell are you using?
cmd
Log output