Use your Gnu $LS_COLORS
or BSD $LSCOLORS
to generate a coherent theme for git
, less
,
grep
, and your Zsh prompt, completions and command line. Don't know how to or don't feel like
customizing your colors? No worries: Z Colors comes with an excellent default theme, too.
Enjoy this software? Become a sponsor!
Once you've installed Z Colors with the steps below, then your theme is
automatically applied to git
, less
, grep
plus Zsh completions and
command line. No other steps are required for these.
For adding colors to your prompt, Z Colors provides an associative array $zcolor
containing the
theme values for file types di
, ln
, so
, pi
, ex
, bd
, cd
, su
, sg
, tw
and ow
.
You can use it like this:
# $'...': string with support for `print` escape codes
# %{<esc>%}: Tell the prompt that <esc> is zero-width output.
# %{\e[0m%}: Reset all colors and other highlighting.
# %~: present working dir; %#: `%` for normal user, `#` for root
PS1=$'%{\e['$zcolor[di]$'m%}%~%{\e[m%}/ %# '
If you use $LS_COLORS
, then the values for di
, ln
, so
, pi
, ex
, bd
, cd
, su
, sg
,
tw
and ow
need to contain 3- or 4-bit colors only. 8- and 24-bit colors are currently not
supported!
For your theme be used to highlight your command line, you will need to also install
zsh-syntax-highlighting
.
Using Znap (recommended):
- In your
~/.zshrc
file, add:znap source marlonrichert/zcolors znap eval zcolors "zcolors ${(q)LS_COLORS}"
- To update, do:
% znap pull
Manually:
- On the command line, do:
% cd ~/Git # or wherever you keep your Git repos/Zsh plugins % git clone https://github.com/marlonrichert/zcolors.git % autoload -Uz ~/Git/zcolors/functions/zcolors % zcolors >| ~/.zcolors
- In your
~/.zshrc
file, add:source ~/Git/zcolors/zcolors.plugin.zsh source ~/.zcolors # generated in step 1
- To update, do:
% git -C ~/Git/zcolors pull
- Whenever you change your
$LS_COLORS
, do:% zcolors >| ~/.zcolors