Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.47k stars 947 forks source link

Fix prompt status error #1250

Closed MichaelAquilina closed 5 years ago

MichaelAquilina commented 5 years ago

Fix prompt_status error message - [Bugfix]

Description

I pull this plugin from the next branch (for the new features it provides). Recently I've noticed that my local machine shows the following error on startup:

prompt_status:16: bad math expression: operand expected at end of string

Looking into it, it seems like both the ec and the ec_sum variable are not being initialised. This results in an incorrect arithmetic expression of $(( + )) being evaluated.

The actual solution for this might be to actually fix the underlying cause but I though this PR would be appropriate to start a discussion about where the issue might be and why it is showing up for me specifically.

dritter commented 5 years ago

Thanks for the PR @MichaelAquilina . The code looks solid to me. RETVAL and RETVALS are initialised in __p9k_save_retvals, which is defined in generators/default.p9k. In my tests the exit code was always set correctly. Do you have some special ZSH options set?

I'm merging this fix any way, as it is nice and small. Thank you very much.

MichaelAquilina commented 5 years ago

Would be interesting to see why my specific case is failing.

The settings I have set for powerlevel are the following

# Theme
zplug "bhilburn/powerlevel9k", as:theme, at:next
P9K_LEFT_PROMPT_ELEMENTS=(status dir vcs dir_writable)
P9K_RIGHT_PROMPT_ELEMENTS=()
P9K_DIR_SHORTEN_STRATEGY="dir"
P9K_DIR_SHORTEN_LENGTH=2
P9K_VIRTUALENV_BACKGROUND="cyan"
Syphdias commented 5 years ago

@MichaelAquilina Could you try putting the zplug line to the end?

MichaelAquilina commented 5 years ago

@Syphdias still the same issue. The plugin is not loaded at the zplug command. Its loaded at a later step when zplug load is run.