init.zsh 3.3 KB

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