[Solved] Background and foreground colors for xterm

Hi all,

I used the code given by cfajohnson on this forum to generate background colors for xterm.

Thanks cfajohnson... (sorry wasnt allowed to past the complete url)

n=200  ## adjust to taste: higher value, lighter background n1=$(( 256 - $n )) bg=$( printf "#%x%x%x\n" $(( $RANDOM % $n1 + $n )) \                          $(( $RANDOM % $n1 + $n )) \                          $(( $RANDOM % $n1 + $n )) ) xterm -bg "$bg" & 

Could someone help me to come up with a foreground color that has good visibility based on thebackground color generated by the script?.

Try:

n=200 ## adjust to taste: higher value, lighter background and darker foreground
n1=$(( 256 - $n ))
bg=$( printf "#%02x%02x%02x\n" \
   $(( $RANDOM % $n1 + $n )) \
   $(( $RANDOM % $n1 + $n )) \
   $(( $RANDOM % $n1 + $n )))
fg=$( printf "#%02x%02x%02x\n" \
   $(( $RANDOM % $n1 )) \
   $(( $RANDOM % $n1 )) \
   $(( $RANDOM % $n1 )))
1 Like

That worked..Thanks.