nojhan / lp-gitcrux

A theme for liquidprompt giving visual hints about what Git command to use, given the state of the current Git repository.
GNU Affero General Public License v3.0
1 stars 0 forks source link

Theme does not work on zsh #1

Open nigiord opened 10 months ago

nigiord commented 10 months ago

When trying to use the theme on zsh, we obtain multiple errors everytime it tries to display an arrow.

lp_terminal_format:11: bad math expression: operator expected at `195 0'
lp_terminal_format:13: bad math expression: operator expected at `195 0'
lp_terminal_format:15: bad math expression: operator expected at `195 0'
lp_terminal_format:17: bad math expression: operator expected at `195 0'

Apparently this might be related to the way zsh "expands" strings when given as arguments to a new function. For instance here:

https://github.com/nojhan/lp-gitcrux/blob/623edecd0c0accfc8375b394e5828c4ff4cfaa0e/gitcrux.theme#L48

In Bash this is equivalent to lp_terminal_format 0 195 0 while in zsh it is lp_terminal_format "0 195 0". The second version both fails in bash and zsh if you try to type it in the command line, because lp_terminal_format expects 3 arguments.

One way to fix that in zsh is to use the z modifier like this: lp_terminal_format ${(z)color}. Unfortunately this is not compatible with bash, meaning we will have to test the environment everytime using _LP_SHELL_zshand _lp_SHELL_bash, making the code way more cumbersome.

There might be a better way to fix that that I’m not aware of.

nojhan commented 10 months ago

Thanks for the report! Should be fixed by 5ab3210, tested on Zsh 5.8.1, please test.

nigiord commented 6 months ago

Looks good on zsh 5.9 (x86_64-apple-darwin23.0) :+1: Thanks!