From 708248bf27629139d39ff80f44bf83bce81fecbb Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 15 Sep 2017 16:35:08 -0500 Subject: [PATCH] Add Display All The Terminal Colors as a unix til --- README.md | 3 ++- unix/display-all-the-terminal-colors.md | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 unix/display-all-the-terminal-colors.md diff --git a/README.md b/README.md index 8439eb6..86a56e7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_559 TILs and counting..._ +_560 TILs and counting..._ --- @@ -490,6 +490,7 @@ _559 TILs and counting..._ - [Create A File Descriptor with Process Substitution](unix/create-a-file-descriptor-with-process-substitution.md) - [Curling For Headers](unix/curling-for-headers.md) - [Curling With Basic Auth Credentials](unix/curling-with-basic-auth-credentials.md) +- [Display All The Terminal Colors](unix/display-all-the-terminal-colors.md) - [Display Free Disk Space](unix/display-free-disk-space.md) - [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md) - [Exclude A Directory With Find](unix/exclude-a-directory-with-find.md) diff --git a/unix/display-all-the-terminal-colors.md b/unix/display-all-the-terminal-colors.md new file mode 100644 index 0000000..65c4f59 --- /dev/null +++ b/unix/display-all-the-terminal-colors.md @@ -0,0 +1,23 @@ +# Display All The Terminal Colors + +The following snippet of bash scripting will print out a nicely formatted +collection of all the terminal colors. + +```bash +for x in {0..8}; do + for i in {30..37}; do + for a in {40..47}; do + echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m " + done + echo + done +done +echo "" +``` + +This is a great way to figure out the escape codes you need for coloring and +styling text in a bash script. + +[source](https://askubuntu.com/questions/27314/script-to-display-all-terminal-colors) + +h/t Dillon Hafer