Created
October 23, 2018 04:16
-
-
Save dungdm93/03b976913ce137175f1bf344bfd913d7 to your computer and use it in GitHub Desktop.
Colorize terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
##### Color table ##### | |
# Black 0;30 Dark Gray 1;30 | |
# Red 0;31 Light Red 1;31 | |
# Green 0;32 Light Green 1;32 | |
# Brown/Orange 0;33 Yellow 1;33 | |
# Blue 0;34 Light Blue 1;34 | |
# Purple 0;35 Light Purple 1;35 | |
# Cyan 0;36 Light Cyan 1;36 | |
# Light Gray 0;37 White 1;37 | |
if [ -t 1 ]; then # if terminal | |
ncolors=$(which tput > /dev/null && tput colors) # supports color | |
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then | |
termcols="$(tput cols)" | |
bold="$(tput bold)" | |
underline="$(tput smul)" | |
standout="$(tput smso)" | |
normal="$(tput sgr0)" | |
black="$(tput setaf 0)" | |
red="$(tput setaf 1)" | |
green="$(tput setaf 2)" | |
yellow="$(tput setaf 3)" | |
blue="$(tput setaf 4)" | |
magenta="$(tput setaf 5)" | |
cyan="$(tput setaf 6)" | |
white="$(tput setaf 7)" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment