Skip to content

Instantly share code, notes, and snippets.

@Guitsmstr
Last active February 25, 2023 15:23
Show Gist options
  • Save Guitsmstr/1cb565e30fb4a7c0466288367f3aec94 to your computer and use it in GitHub Desktop.
Save Guitsmstr/1cb565e30fb4a7c0466288367f3aec94 to your computer and use it in GitHub Desktop.
change bash theme to 256 colors (oh-my-bash) #bash #oh-my-bash #color

Change colors of oh-my-bash themes

this is a script to see the bash colors (paste it in terminal):

 iter=16
    while [ $iter -lt 52 ]
    do
        second=$[$iter+36]
        third=$[$second+36]
        four=$[$third+36]
        five=$[$four+36]
        six=$[$five+36]
        seven=$[$six+36]
        if [ $seven -gt 250 ];then seven=$[$seven-251]; fi

        echo -en "\033[38;5;$(echo $iter)m█ "
        printf "%03d" $iter
        echo -en "   \033[38;5;$(echo $second)m█ "
        printf "%03d" $second
        echo -en "   \033[38;5;$(echo $third)m█ "
        printf "%03d" $third
        echo -en "   \033[38;5;$(echo $four)m█ "
        printf "%03d" $four
        echo -en "   \033[38;5;$(echo $five)m█ "
        printf "%03d" $five
        echo -en "   \033[38;5;$(echo $six)m█ "
        printf "%03d" $six
        echo -en "   \033[38;5;$(echo $seven)m█ "
        printf "%03d" $seven

        iter=$[$iter+1]
        printf '\r\n'
    done
    

'oh-my-bash' have this color variables:

fg_color() {
101   ¦ case "$1" in
1   ¦ ¦ ¦ black)      echo 30;;
2   ¦ ¦ ¦ red)        echo 31;;
3   ¦ ¦ ¦ green)      echo 32;;
4   ¦ ¦ ¦ yellow)     echo 33;;
5   ¦ ¦ ¦ blue)       echo 34;;
6   ¦ ¦ ¦ magenta)    echo 35;;
7   ¦ ¦ ¦ cyan)       echo 36;;
8   ¦ ¦ ¦ white)      echo 37;;
9   ¦ ¦ ¦ orange)     echo 38\;5\;166;;
10   ¦ ¦ ¦ greene)     echo 38\;5\;82;;
11   ¦ esac
12 } 
13 
14 bg_color() { 
15   ¦ case "$1" in
16   ¦ ¦ ¦ black)      echo 40;;
17   ¦ ¦ ¦ red)        echo 41;;
18   ¦ ¦ ¦ green)      echo 42;;
19   ¦ ¦ ¦ yellow)     echo 43;;
20   ¦ ¦ ¦ blue)       echo 44;;
21   ¦ ¦ ¦ magenta)    echo 45;;
22   ¦ ¦ ¦ cyan)       echo 46;;
23   ¦ ¦ ¦ white)      echo 47;;
24   ¦ ¦ ¦ orange)     echo 48\;5\;166;;
25 | ¦ ¦ ¦ greene)     echo 48\;5\;82;;
26   ¦ esac;
27 } 

fg_colors: is foreground color and it refers to the font color. bg_colors: is background colors and set the background color.

you can add new colors like greene whit the syntax below:

colorname)      echo 48\;5\;82;;

important: if you want to add a new font color you have to replace 48 by 38.

if you see in the colors pallete printed in the terminal, the last number of grenne match with the green color that have the number 82.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment