File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Source: https://github.com/molovo/color
2+ # License: MIT — Copyright (c) 2015 Joe Letchford
3+ # Maintained by z-shell/src — https://github.com/z-shell/src
4+ #
5+ #! /usr/bin/env zsh
6+
7+ function color() {
8+ local color=$1 style=$2 b=0
9+
10+ shift
11+
12+ case $style in
13+ bold|b) b=1; shift ;;
14+ italic|i) b=2; shift ;;
15+ underline|u) b=4; shift ;;
16+ inverse|in) b=7; shift ;;
17+ strikethrough|s) b=9; shift ;;
18+ esac
19+
20+ case $color in
21+ black|b) echo " \033[${b} ;30m${@ } \033[0;m" ;;
22+ red|r) echo " \033[${b} ;31m${@ } \033[0;m" ;;
23+ green|g) echo " \033[${b} ;32m${@ } \033[0;m" ;;
24+ yellow|y) echo " \033[${b} ;33m${@ } \033[0;m" ;;
25+ blue|bl) echo " \033[${b} ;34m${@ } \033[0;m" ;;
26+ magenta|m) echo " \033[${b} ;35m${@ } \033[0;m" ;;
27+ cyan|c) echo " \033[${b} ;36m${@ } \033[0;m" ;;
28+ white|w) echo " \033[${b} ;37m${@ } \033[0;m" ;;
29+ * ) echo " \033[${b} ;38;5;$(( ${color} )) m${@ } \033[0;m" ;;
30+ esac
31+ }
32+
33+ color " $@ "
You can’t perform that action at this time.
0 commit comments