added colors

This commit is contained in:
Holger Sielaff
2025-10-26 21:52:57 +01:00
parent 6d16fb3f2f
commit 5466fa5fcd
3 changed files with 51 additions and 0 deletions

View File

@@ -19,3 +19,5 @@ alias -- -="cd -"
shopt -s autocd
shopt -s cdspell
# source $HOME/.local/lib/colors.sh

44
colors.sh Executable file
View File

@@ -0,0 +1,44 @@
colors() {
for i in {31..38}; do
echo -ne "\e[${i}m"
if [[ "${@}" =~ -f ]]; then
echo "color_$i() {"
echo " echo -e \"\\e[${i}m\${@}\\e[0m\""
echo "}"
else
echo $i
fi
echo -ne "\e[0m"
done
}
colored(){
declare -A local _colored=(["red"]=31 ["brown"]=33 ["blue"]=34 ["magenta"]=35 ["log"]=36 ["light"]=37)
local _keys="^$(echo "${!_colored[@]}" | sed 's/ /|/g')$"
if [[ "$1" =~ $_keys ]]; then
_color="${_colored[$1]}"
shift
else
_color="0"
fi
echo -e "\e[${_color}m${@}\e[0m"
}
txt_error(){
colored "red" ${@}
}
txt_info(){
colored "blue" ${@}
}
txt_darkblue(){
colored "blue" ${@}
}
txt_message(){
colored "magenta" ${@}
}
txt_magenta(){
colored "magenta" ${@}
}
txt_blue(){
colored "log" ${@}
}

View File

@@ -0,0 +1,5 @@
#!/bin/bash
set -e
for d in /home/*/Desktop/tmp; do
echo $d
done