-
-
Notifications
You must be signed in to change notification settings - Fork 970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for configuring colors with zstyle #472
Conversation
Any chance this will be merged soon? |
c210cee
to
044b21c
Compare
103e822
to
202b97f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this @bricewge, much appreciated!
6570bea
to
3f018b0
Compare
The updated PR add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is shaping up nicely!
There were a few quirks with zstyle
that caught my eye, but in general I'm liking the look of this.
Can you fix the merge conflict? |
@LitoMore Thanks for the heads-up, I forgot that your PR got merged. |
Available colors: - exec_time - git:arrow - git:branch - git:branch:cached - host - path - prompt:error - prompt:success - user - user:root, default color changed from `white` to `default` - virtualenv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aww yeah 😎! LGTM!
Did a quick trial run, tweaking the colors is pretty fun.
zstyle :prompt:pure:exec_time color 225
zstyle :prompt:pure:git:arrow color 220
zstyle :prompt:pure:git:branch color 106
zstyle :prompt:pure:host color 30
zstyle :prompt:pure:path color 230
zstyle :prompt:pure:prompt:error color 196
zstyle :prompt:pure:prompt:success color 222
zstyle :prompt:pure:user color 36
I think this should be documented #472 (comment) as being possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be documented #472 (comment) as being possible.
What do you mean? If it's deleting a style, I don't think it's necessary because zstyle use the most specific and latest zstyle when queried and it will only make sense when testing. Or do you mean that when a style is deleted it return to it's default value which I also don't think is needed to be specified since it follow the principle of least astonishment.
zstyle
usage is best left to the manual because of all it's quirk, even @mafredri already fell into on of it's pothole #472 (comment).
readme.md
Outdated
As explained in ZSH's[manual](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting) color values can be: | ||
- a decimal integer up to the maximal number of color your terminal support | ||
- the name of one of the following nine colours: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` and `default` (the terminal’s default foreground) | ||
- ‘#’ followed by an RGB triplet in hexadecimal format (ex. `#424242`), *only* if your terminal support 24bit colors or when the module [`zsh/nearcolor`](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fnearcolor-Module) is loaded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should show an example of loading zsh/nearcolor
and using a HEX color in the Example section. I think a lot of users will want this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
readme.md
Outdated
@@ -96,6 +96,11 @@ prompt pure | |||
|
|||
## Colors | |||
|
|||
As explained in ZSH's[manual](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting) color values can be: | |||
- a decimal integer up to the maximal number of color your terminal support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the decimal integer represent? How can users find the number they want? Those are some questions we should answer.
In general, we should not force users to read the horrible ZSH manual to achieve things most user would want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have explained what it represent but the way to find the which color that I can't explain because it is terminal specific.
Now I understand the reason behind all your comments on the documentation side. And I'm happy to see I'm not the only one thinking that this manual isn't well written! Hell I have even found this gem in the manual:
[...] the Zsh Development Group accepts no responsibility for any brain damage which may occur during the reading [...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it good this time?
readme.md
Outdated
@@ -96,6 +96,11 @@ prompt pure | |||
|
|||
## Colors | |||
|
|||
As explained in ZSH's[manual](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting) color values can be: | |||
- a decimal integer up to the maximal number of color your terminal support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have explained what it represent but the way to find the which color that I can't explain because it is terminal specific.
Now I understand the reason behind all your comments on the documentation side. And I'm happy to see I'm not the only one thinking that this manual isn't well written! Hell I have even found this gem in the manual:
[...] the Zsh Development Group accepts no responsibility for any brain damage which may occur during the reading [...]
readme.md
Outdated
As explained in ZSH's[manual](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting) color values can be: | ||
- a decimal integer up to the maximal number of color your terminal support | ||
- the name of one of the following nine colours: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` and `default` (the terminal’s default foreground) | ||
- ‘#’ followed by an RGB triplet in hexadecimal format (ex. `#424242`), *only* if your terminal support 24bit colors or when the module [`zsh/nearcolor`](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fnearcolor-Module) is loaded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This looks good to me now. @bricewge, Thanks for contributing 🙌 |
It's out now: https://twitter.com/sindresorhus/status/1141729038068641797 🎉 |
Huge thanks for this! Huge win for accessibility for |
@bricewge Is zsh 5.2 a new enough version for this change? I started getting |
I can confirm that reverting this diff fixes pure on zsh 5.2. I think it'd be good to make pure work for this version because it is the current stable one used by CentOS. |
@jonmorton 5.2 is supported, this was a regression. Thanks for reporting, it's fixed in 1.10.2. Btw, I even use Pure on 4.3.17 or 5.0.2, occasionally 😛. Btw, next time please open up a new issue as it helps with tracking 😄. |
* upstream/master: (25 commits) Fix incorrect color name in the readme (sindresorhus#482) 1.10.3 Fix username prompt expansion 1.10.2 Bump version number in pure state Fix bad set of key/value pairs on old versions of ZSH 1.10.1 Suppress warning of WARN_CREATE_GLOBAL option (sindresorhus#479) 1.10.0 Update the zsh-async version to reflect the code Improve code comments Avoid performing prompt reset in zle-line-finish hook (sindresorhus#477) Add support for configuring colors with zstyle (sindresorhus#472) Improve the style of the continuation prompt (PS2) (sindresorhus#323) Fix username color (sindresorhus#450) Add `prompt_pure_system_report` for reporting issues (sindresorhus#468) Add pure10k to the list of ports (sindresorhus#474) Create funding.yml Add pure-pwsh to the ports section of the readme (sindresorhus#467) Skip grep fork, use native zsh matching (sindresorhus#459) ...
* upstream/master: Fix incorrect color name in the readme (sindresorhus#482) 1.10.3 Fix username prompt expansion 1.10.2 Bump version number in pure state Fix bad set of key/value pairs on old versions of ZSH 1.10.1 Suppress warning of WARN_CREATE_GLOBAL option (sindresorhus#479) 1.10.0 Update the zsh-async version to reflect the code Improve code comments Avoid performing prompt reset in zle-line-finish hook (sindresorhus#477) Add support for configuring colors with zstyle (sindresorhus#472) Improve the style of the continuation prompt (PS2) (sindresorhus#323) Fix username color (sindresorhus#450) Add `prompt_pure_system_report` for reporting issues (sindresorhus#468) Add pure10k to the list of ports (sindresorhus#474) Create funding.yml # Conflicts: # package.json # pure.zsh # readme.md
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
Following the discussion at #306 this PR add the capacity to change the colors of
pure
by usingzstyle
to avoid polluting the global name space.Available colors:
Fixes #126
Fixes #303
Fixes #306
Fixes #389
Closes #256
Closes #450
EDIT: Add requested colors.