added colors.sh
parent
9e51b49535
commit
265586b13c
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2034
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2012-06-25 15:20:39 +0100
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
# ============================================================================ #
|
||||
# Terminal ANSI Escape Color Codes
|
||||
# ============================================================================ #
|
||||
|
||||
# Show color codes - adapted from http://codesnippets.joyent.com/posts/show/1517 example 1
|
||||
#
|
||||
# see also colors.pl from DevOps-Perl-tools repo which is slightly better
|
||||
colors(){
|
||||
local text="hari"
|
||||
|
||||
echo -e "\n 40m 41m 42m 43m 44m 45m 46m 47m";
|
||||
|
||||
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
|
||||
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
|
||||
' 36m' '1;36m' ' 37m' '1;37m'; do
|
||||
FG=${FGs// /}
|
||||
echo -en " $FGs \033[$FG $text "
|
||||
for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
|
||||
echo -en "$EINS \033[$FG\033[$BG $text \033[0m";
|
||||
done
|
||||
echo
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
# ============================================================================ #
|
||||
|
||||
# For Gentoo stylish prompts
|
||||
#
|
||||
# Find or write a full colour output table like seen here:
|
||||
# Daniel Robbins prompt magic tip on ibm developerworks
|
||||
#
|
||||
# from http://wiki.archlinux.org/index.php/Color_Bash_Prompt
|
||||
#
|
||||
# would set 'readonly' but causes reloads to output readonly variable errors
|
||||
txtblk='\e[0;30m' # Black - Regular
|
||||
txtred='\e[0;31m' # Red
|
||||
txtgrn='\e[0;32m' # Green
|
||||
txtylw='\e[0;33m' # Yellow
|
||||
txtblu='\e[0;34m' # Blue
|
||||
txtpur='\e[0;35m' # Purple
|
||||
txtcyn='\e[0;36m' # Cyan
|
||||
txtwht='\e[0;37m' # White
|
||||
bldblk='\e[1;30m' # Black - Bold
|
||||
bldred='\e[1;31m' # Red
|
||||
bldgrn='\e[1;32m' # Green
|
||||
bldylw='\e[1;33m' # Yellow
|
||||
bldblu='\e[1;34m' # Blue
|
||||
bldpur='\e[1;35m' # Purple
|
||||
bldcyn='\e[1;36m' # Cyan
|
||||
bldwht='\e[1;37m' # White
|
||||
unkblk='\e[4;30m' # Black - Underline
|
||||
undred='\e[4;31m' # Red
|
||||
undgrn='\e[4;32m' # Green
|
||||
undylw='\e[4;33m' # Yellow
|
||||
undblu='\e[4;34m' # Blue
|
||||
undpur='\e[4;35m' # Purple
|
||||
undcyn='\e[4;36m' # Cyan
|
||||
undwht='\e[4;37m' # White
|
||||
bakblk='\e[40m' # Black - Background
|
||||
bakred='\e[41m' # Red
|
||||
bakgrn='\e[42m' # Green
|
||||
bakylw='\e[43m' # Yellow
|
||||
bakblu='\e[44m' # Blue
|
||||
bakpur='\e[45m' # Purple
|
||||
bakcyn='\e[46m' # Cyan
|
||||
bakwht='\e[47m' # White
|
||||
txtrst='\e[0m' # Text Reset
|
Loading…
Reference in New Issue