-
-
Save rtulke/ec8b2cff14822cd9e6742827d28eaef1 to your computer and use it in GitHub Desktop.
Revisions
-
rene-d revised this gist
Jul 24, 2018 . 2 changed files with 9 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,12 +29,18 @@ class Colors: END = "\033[0m" # cancel SGR codes if we don't write to a terminal if not __import__("sys").stdout.isatty(): for _ in dir(): if isinstance(_, str) and _[0] != "_": locals()[_] = "" else: # set Windows console in VT mode if __import__("platform").system() == "Windows": kernel32 = __import__("ctypes").windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) del kernel32 if __name__ == '__main__': for i in dir(Colors): if i[0:1] != "_" and i != "END": print("{:>16} {}".format(i, getattr(Colors, i) + i + Colors.END)) Empty file. -
rene-d revised this gist
Jul 24, 2018 . 2 changed files with 77 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # SGR color constants # rene-d 2018 class Colors: """ ANSI color codes """ @@ -32,9 +34,7 @@ class Colors: locals()[c] = "" else: # set Windows console in VT mode if __import__("platform").system() == "Windows": kernel32 = __import__("ctypes").windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,73 @@ #! /bin/bash # rene-d 2015 # définition de constantes SGR pour affichage de couleur # exemple: echo -e ${COLOR_RED}rouge${COLOR_END} if ! tty -s; then # ne pas changer l'indentation des lignes suivantes COLOR_BLACK="" COLOR_RED="" COLOR_GREEN="" COLOR_BROWN="" COLOR_BLUE="" COLOR_PURPLE="" COLOR_CYAN="" COLOR_LIGHT_GRAY="" COLOR_DARK_GRAY="" COLOR_LIGHT_RED="" COLOR_LIGHT_GREEN="" COLOR_YELLOW="" COLOR_LIGHT_BLUE="" COLOR_LIGHT_PURPLE="" COLOR_LIGHT_CYAN="" COLOR_LIGHT_WHITE="" COLOR_BOLD="" COLOR_FAINT="" COLOR_ITALIC="" COLOR_UNDERLINE="" COLOR_BLINK="" COLOR_NEGATIVE="" COLOR_CROSSED="" COLOR_END="" else # ne pas indenter les lignes suivantes (pour le sed suivant) COLOR_BLACK="\033[0;30m" COLOR_RED="\033[0;31m" COLOR_GREEN="\033[0;32m" COLOR_BROWN="\033[0;33m" COLOR_BLUE="\033[0;34m" COLOR_PURPLE="\033[0;35m" COLOR_CYAN="\033[0;36m" COLOR_LIGHT_GRAY="\033[0;37m" COLOR_DARK_GRAY="\033[1;30m" COLOR_LIGHT_RED="\033[1;31m" COLOR_LIGHT_GREEN="\033[1;32m" COLOR_YELLOW="\033[1;33m" COLOR_LIGHT_BLUE="\033[1;34m" COLOR_LIGHT_PURPLE="\033[1;35m" COLOR_LIGHT_CYAN="\033[1;36m" COLOR_LIGHT_WHITE="\033[1;37m" COLOR_BOLD="\033[1m" COLOR_FAINT="\033[2m" COLOR_ITALIC="\033[3m" COLOR_UNDERLINE="\033[4m" COLOR_BLINK="\033[5m" COLOR_NEGATIVE="\033[7m" COLOR_CROSSED="\033[9m" # ne pas changer l'indentation des lignes suivantes COLOR_END="\033[0m" fi # affiche les couleurs if [ "$1" = "-h" ] ; then for i in `cat $0 | sed -e 's/^\(COLOR.*\)=\(.*\)/\1/p;d'`; do [ "$i" != "COLOR_END" ] && echo -e ${!i}$i${COLOR_END} done fi -
rene-d revised this gist
Jul 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -37,4 +37,4 @@ class Colors: import ctypes kernel32 = ctypes.windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) -
rene-d revised this gist
Jul 15, 2018 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -30,3 +30,11 @@ class Colors: for c in dir(): if isinstance(c, str) and c[0:2] != "__": locals()[c] = "" else: # set Windows console in VT mode import platform if platform.system() == "Windows": import ctypes kernel32 = ctypes.windll.kernel32 kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7) kernel32.SetConsoleMode(kernel32.GetStdHandle(-12), 7) -
rene-d created this gist
Jun 30, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ class Colors: """ ANSI color codes """ BLACK = "\033[0;30m" RED = "\033[0;31m" GREEN = "\033[0;32m" BROWN = "\033[0;33m" BLUE = "\033[0;34m" PURPLE = "\033[0;35m" CYAN = "\033[0;36m" LIGHT_GRAY = "\033[0;37m" DARK_GRAY = "\033[1;30m" LIGHT_RED = "\033[1;31m" LIGHT_GREEN = "\033[1;32m" YELLOW = "\033[1;33m" LIGHT_BLUE = "\033[1;34m" LIGHT_PURPLE = "\033[1;35m" LIGHT_CYAN = "\033[1;36m" LIGHT_WHITE = "\033[1;37m" BOLD = "\033[1m" FAINT = "\033[2m" ITALIC = "\033[3m" UNDERLINE = "\033[4m" BLINK = "\033[5m" NEGATIVE = "\033[7m" CROSSED = "\033[9m" END = "\033[0m" # cancel SGR codes if we don't write to a terminal if not __import__("sys").stdout.isatty(): for c in dir(): if isinstance(c, str) and c[0:2] != "__": locals()[c] = ""