This commit is contained in:
Andrey Anurin
2016-05-16 23:46:33 -07:00
commit 916d13f93e
412 changed files with 37846 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
Spectrum
========
Provides for easier use of 256 colors and effects.
To learn more about text formatting, read [A Guide to 256 Color Codes][1].
Variables
---------
- `BG` provides background colors.
- `FG` provides foreground colors.
- `FX` provides effects.
### Background and Foreground
Terminals support 8, 16, 88, and 256 colors. Check if a terminal supports 256
colors with `tput colors` before use.
The following colors are supported.
- 0 to 255
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
### Effects
Though there are many effects, most terminals support at least bold formatting.
**Not all effects work on all terminals; use them sparingly.**
| Enable | Disable |
| ------------------------- | ---------------------------- |
| | none |
| | normal |
| bold | no-bold |
| faint | no-faint |
| standout | no-standout |
| underline | no-underline |
| blink | no-blink |
| fast-blink | no-fast-blink |
| reverse | no-reverse |
| conceal | no-conceal |
| strikethrough | no-strikethrough |
| gothic | no-gothic |
| double-underline | no-double-underline |
| proportional | no-proportional |
| overline | no-overline |
| | |
| | no-border |
| border-rectangle | no-border-rectangle |
| border-circle | no-border-circle |
| | |
| | no-ideogram-marking |
| underline-or-right | no-underline-or-right |
| double-underline-or-right | no-double-underline-or-right |
| overline-or-left | no-overline-or-left |
| double-overline-or-left | no-double-overline-or-left |
| stress | no-stress |
| | |
| | font-default |
| font-first | no-font-first |
| font-second | no-font-second |
| font-third | no-font-third |
| font-fourth | no-font-fourth |
| font-fifth | no-font-fifth |
| font-sixth | no-font-sixth |
| font-seventh | no-font-seventh |
| font-eigth | no-font-eigth |
| font-ninth | no-font-ninth |
### Plain Text
Use `$BG[none]`, `$FG[none]`, or `$FX[none]` to turn off formatting.
Authors
-------
*The authors of this module should be contacted via the [issue tracker][2].*
- [P.C. Shyamshankar](https://github.com/sykora)
- [Sorin Ionescu](https://github.com/sorin-ionescu)
[1]: http://lucentbeing.com/writing/archives/a-guide-to-256-color-codes/
[2]: https://github.com/sorin-ionescu/prezto/issues

View File

@@ -0,0 +1,69 @@
#
# Provides for easier use of 256 colors and effects.
#
# Authors:
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if [[ "$TERM" == 'dumb' ]]; then
return 1
fi
typeset -gA FX FG BG
FX=(
none "\e[00m"
normal "\e[22m"
bold "\e[01m" no-bold "\e[22m"
faint "\e[02m" no-faint "\e[22m"
standout "\e[03m" no-standout "\e[23m"
underline "\e[04m" no-underline "\e[24m"
blink "\e[05m" no-blink "\e[25m"
fast-blink "\e[06m" no-fast-blink "\e[25m"
reverse "\e[07m" no-reverse "\e[27m"
conceal "\e[08m" no-conceal "\e[28m"
strikethrough "\e[09m" no-strikethrough "\e[29m"
gothic "\e[20m" no-gothic "\e[22m"
double-underline "\e[21m" no-double-underline "\e[22m"
proportional "\e[26m" no-proportional "\e[50m"
overline "\e[53m" no-overline "\e[55m"
no-border "\e[54m"
border-rectangle "\e[51m" no-border-rectangle "\e[54m"
border-circle "\e[52m" no-border-circle "\e[54m"
no-ideogram-marking "\e[65m"
underline-or-right "\e[60m" no-underline-or-right "\e[65m"
double-underline-or-right "\e[61m" no-double-underline-or-right "\e[65m"
overline-or-left "\e[62m" no-overline-or-left "\e[65m"
double-overline-or-left "\e[63m" no-double-overline-or-left "\e[65m"
stress "\e[64m" no-stress "\e[65m"
font-default "\e[10m"
font-first "\e[11m" no-font-first "\e[10m"
font-second "\e[12m" no-font-second "\e[10m"
font-third "\e[13m" no-font-third "\e[10m"
font-fourth "\e[14m" no-font-fourth "\e[10m"
font-fifth "\e[15m" no-font-fifth "\e[10m"
font-sixth "\e[16m" no-font-sixth "\e[10m"
font-seventh "\e[17m" no-font-seventh "\e[10m"
font-eigth "\e[18m" no-font-eigth "\e[10m"
font-ninth "\e[19m" no-font-ninth "\e[10m"
)
FG[none]="$FX[none]"
BG[none]="$FX[none]"
colors=(black red green yellow blue magenta cyan white)
for color in {0..255}; do
if (( $color >= 0 )) && (( $color < $#colors )); then
index=$(( $color + 1 ))
FG[$colors[$index]]="\e[38;5;${color}m"
BG[$colors[$index]]="\e[48;5;${color}m"
fi
FG[$color]="\e[38;5;${color}m"
BG[$color]="\e[48;5;${color}m"
done
unset color{s,} index