color.sh 683 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. echo=echo
  11. for cmd in echo /bin/echo; do
  12. $cmd >/dev/null 2>&1 || continue
  13. if ! $cmd -e "" | grep -qE '^-e'; then
  14. echo=$cmd
  15. break
  16. fi
  17. done
  18. CSI=$($echo -e "\033[")
  19. CEND="${CSI}0m"
  20. CDGREEN="${CSI}32m"
  21. CRED="${CSI}1;31m"
  22. CGREEN="${CSI}1;32m"
  23. CYELLOW="${CSI}1;33m"
  24. CBLUE="${CSI}1;34m"
  25. CMAGENTA="${CSI}1;35m"
  26. CCYAN="${CSI}1;36m"
  27. CSUCCESS="$CDGREEN"
  28. CFAILURE="$CRED"
  29. CQUESTION="$CMAGENTA"
  30. CWARNING="$CYELLOW"
  31. CMSG="$CCYAN"