Skip to content

Commit

Permalink
fixup! configure colors with zstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
bricewge committed Jun 18, 2019
1 parent 0b063af commit 9936741
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pure.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ prompt_pure_preprompt_render() {
# Username and machine, if applicable.
[[ -n $prompt_pure_state[username] ]] && preprompt_parts+=('${prompt_pure_state[username]}')
# Execution time.
[[ -n $prompt_pure_cmd_exec_time ]] && preprompt_parts+=('%F{$prompt_pure_colors[exec_time]}${prompt_pure_cmd_exec_time}%f')
[[ -n $prompt_pure_cmd_exec_time ]] && preprompt_parts+=('%F{$prompt_pure_colors[execution_time]}${prompt_pure_cmd_exec_time}%f')

local cleaned_ps1=$PROMPT
local -H MATCH MBEGIN MEND
Expand Down Expand Up @@ -650,7 +650,7 @@ prompt_pure_setup() {
# Set the colors
typeset -gA prompt_pure_colors_default prompt_pure_colors
prompt_pure_colors_default=(
exec_time yellow
execution_time yellow
git:arrow cyan
git:branch 242
git:branch:cached red
Expand Down
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 corresponding to the color index of your terminal, if your `$TERM` is `xterm-256color` see this [chart](https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg)
- 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

Colors can be changed by using [`zstyle`](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fzutil-Module) with a pattern of the form `:prompt:pure:$color_name` and style `color`. The color names, their default, and what part they affect are:
- `exec_time` (yellow) - The execution time of the last command when exceeding `PURE_CMD_MAX_EXEC_TIME`
- `git:arrow` (cyan) - For `PURE_GIT_UP_ARROW` and `PURE_GIT_DOWN_ARROW`
Expand Down Expand Up @@ -125,6 +130,15 @@ venv ❯ | |
virtualenv
```

### RGB colors

There is two way to use RGB colors with the hexadecimal format. The correct way is to use a terminal that support 24bit colors and enable this feature as explained in it's documentation.
If you can't use such terminal the module [`zsh/nearcolor`](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fnearcolor-Module) is here for you, it will map any hexadecimal color to the nearest color in the 88 or 256 color palettes of your termial but without using the first 16 colors since their values can be modifed by the user. Understand that when using this module you won't be able to display true RGB colors, it only allows you to specify colors in a more convenient way. Following is an example on how to use this module:
```sh
# .zshrc
zmodload zsh/nearcolor
zstyle :prompt:pure:path color '#FF0000'
```

## Example

Expand Down

0 comments on commit 9936741

Please sign in to comment.