spectrum.zsh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # A script to make using 256 colors in zsh less painful.
  2. # P.C. Shyamshankar <sykora@lucentbeing.com>
  3. # Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
  4. typeset -AHg FX FG BG
  5. FX=(
  6. reset "%{%}"
  7. bold "%{%}" no-bold "%{%}"
  8. italic "%{%}" no-italic "%{%}"
  9. underline "%{%}" no-underline "%{%}"
  10. blink "%{%}" no-blink "%{%}"
  11. reverse "%{%}" no-reverse "%{%}"
  12. )
  13. for color in {000..255}; do
  14. FG[$color]="%{[38;5;${color}m%}"
  15. BG[$color]="%{[48;5;${color}m%}"
  16. done
  17. # Show all 256 colors with color number
  18. function spectrum_ls() {
  19. local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
  20. for code in {000..255}; do
  21. print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
  22. done
  23. }
  24. # Show all 256 colors where the background is set to specific color
  25. function spectrum_bls() {
  26. local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
  27. for code in {000..255}; do
  28. print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
  29. done
  30. }