From 4a08d33ed0060e91134172bbf006462b5cf046f7 Mon Sep 17 00:00:00 2001 From: tiyn Date: Thu, 9 Oct 2025 05:03:29 +0200 Subject: [PATCH] linux: added shell color usage --- wiki/linux/shell.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/wiki/linux/shell.md b/wiki/linux/shell.md index dbdfb35..81e96c5 100644 --- a/wiki/linux/shell.md +++ b/wiki/linux/shell.md @@ -221,6 +221,29 @@ of these may be escaped if special signs are contained in them. find -type f -exec sed -i "s///g" {} \; ``` +### Using ANSI Color + +ANSI-Colors can easily be used in the shell by using the control sequences as described by +[techstop](https://techstop.github.io/bash-script-colors). +Each color has an own sequence and can be combined to affect the background. +Additionally the font can also be changed using these control sequences. +The following code displays the sequences and makes the control sequences be available from +variables. + +```sh +red="\e[0;91m" +blue="\e[0;94m" +expand_bg="\e[K" +blue_bg="\e[0;104m${expand_bg}" +red_bg="\e[0;101m${expand_bg}" +green_bg="\e[0;102m${expand_bg}" +green="\e[0;92m" +white="\e[0;97m" +bold="\e[1m" +uline="\e[4m" +reset="\e[0m" +``` + ## Error solving This section addresses various problems that can occur and are related to the shell.