You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the example setup in README.md for the jobs module, does not work - as far as I can tell, due to how sub-shells work.
Just use the script in the readme. But for a setup, I removed my zsh config, so I could get this screenshot to show what I'll be talking about below.
Disclaimer that before tonight I did not know about zsh's prompt expansion, or this syntax: ${()}. But because of how strange it looks I knew it didn't come out of nowhere, so I looked into it, and eventually figured out, more or less, what it is trying to do. And after looking at some other examples online, all I did was add a hyphen after the (%):, and viola, we get the number.
Unfortunately, as you can see in the screenshot, simply adding the hyphen still doesn't make the number appear in powerline-go's output, and I don't think it can - at least, with this syntax: ${${(%):-%j}:-0} - with PS1=$(powerline-go ...) since it is being executed in a sub-shell. Now, as for why echo $(echo $?)) works while echo $(echo ${${(%):-%j}:-0}) does not, I can't say.
The reason I'm making this an issue instead of a pull request, is because I'm not familiar enough with the project to know what approach you would prefer to fix this. I've already demonstrated one approach in my screenshot, where the job number could be saved to a variable, and then given to -jobs. But perhaps there is a cleaner solution. Also not sure if ${${(%):%j}:-0} never worked, and it just slipped by due to not many people using the jobs module, or maybe it worked in earlier versions of zsh?
A more readable way to do it would be $(print -P '%j') but this is probably slower than ${${(%):-%j}:-0}. Depends on what kind of balance you want to strike between beginner-friendly, and objectively-better :p.
Edit: I also just tried ${(%):-%j} and still get a number (even if there are zero jobs) so I don't think the :-0 is necessary.
OS: Manjaro
Architecture: Intel
Shell: zsh
The text was updated successfully, but these errors were encountered:
Using the example setup in README.md for the jobs module, does not work - as far as I can tell, due to how sub-shells work.
Just use the script in the readme. But for a setup, I removed my zsh config, so I could get this screenshot to show what I'll be talking about below.
Disclaimer that before tonight I did not know about zsh's prompt expansion, or this syntax:
${()}
. But because of how strange it looks I knew it didn't come out of nowhere, so I looked into it, and eventually figured out, more or less, what it is trying to do. And after looking at some other examples online, all I did was add a hyphen after the(%):
, and viola, we get the number.Unfortunately, as you can see in the screenshot, simply adding the hyphen still doesn't make the number appear in
powerline-go
's output, and I don't think it can - at least, with this syntax:${${(%):-%j}:-0}
- withPS1=$(powerline-go ...)
since it is being executed in a sub-shell. Now, as for whyecho $(echo $?))
works whileecho $(echo ${${(%):-%j}:-0})
does not, I can't say.The reason I'm making this an issue instead of a pull request, is because I'm not familiar enough with the project to know what approach you would prefer to fix this. I've already demonstrated one approach in my screenshot, where the job number could be saved to a variable, and then given to
-jobs
. But perhaps there is a cleaner solution. Also not sure if${${(%):%j}:-0}
never worked, and it just slipped by due to not many people using the jobs module, or maybe it worked in earlier versions of zsh?A more readable way to do it would be
$(print -P '%j')
but this is probably slower than${${(%):-%j}:-0}
. Depends on what kind of balance you want to strike between beginner-friendly, and objectively-better :p.Edit: I also just tried
${(%):-%j}
and still get a number (even if there are zero jobs) so I don't think the:-0
is necessary.The text was updated successfully, but these errors were encountered: