Bash-it / bash-it

A community Bash framework.
MIT License
14.31k stars 2.29k forks source link

rgb color, how to? #218

Closed b00y0h closed 10 years ago

b00y0h commented 11 years ago

it's not clear how to use your own rgb color values for the themes/prompt. could someone please point me in the right direction? thanks

johnnynia commented 10 years ago

Old question, but just stumbled upon it...

As far as my understanding goes, within a terminal emulator you can only opt for the standard 256 colors as shown here. Check also the wikipedia article about the 8-bit color protocol.

For your convenience Bash-it sets up some neat aliases in themes/colors.theme.bash.

tswicegood commented 10 years ago

Whoa -- thanks for the update @johnnynia! @b00y0h, each of the themes are different. Some allow color customization, others don't.

ecotechie commented 7 years ago

Sorry to revive this, but I just don't understand how to change the colors using RGB. zork.theme.bash...

I used this:
my_ps_host="$(color rgb 195 232 141)\h${normal}"; But the color is a pinkish orange, not green.

Looked at colors.theme.bash:

function __color_rgb { r=$1 && g=$2 && b=$3 [[ r == g && g == b ]] && echo $(( $r / 11 + 232 )) && return # gray range above 232 echo "8;5;$(( ($r 36 + $b 6 + $g) / 51 + 16 ))" }

This makes 0 sense to me :( I've spent about an hour reading and following links to no avail. Any help with the syntax?

nwinkler commented 7 years ago

Sorry, can't help you with that. A search in the code showed that the __color_rgb function is not used anywhere.

Not sure who added that function and what it does, sorry...

ecotechie commented 7 years ago

it was added a while back. https://github.com/Bash-it/bash-it/pull/99#issue-3133339

on this file https://github.com/Bash-it/bash-it/blob/569a7a902e133963bd897eee1a1a8173a5a3f66a/themes/colors.theme.bash#L110

Maybe shooting in the dark... thanks at any rate

johnnynia commented 7 years ago

Maybe just use $(green) and then set the color in your terminal emulator's color profile (e.g. on Mac using Terminal.app or iTerm2.app under Settings/Preferences or under Linux using URxvt in .Xresources).

ecotechie commented 7 years ago

Perfect! Not what I was thinking but it did the trick. Thanks