[Solved] Background and foreground colors for xterm

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Background and foreground colors for xterm
# 1  
Old 02-20-2014
[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?.

Last edited by Don Cragun; 02-20-2014 at 06:33 PM.. Reason: Add CODE tags.
# 2  
Old 02-20-2014

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 )))

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 02-21-2014
That worked..Thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move shell script from foreground to background

Hi, Need an urgent help. I have a program executing in foreground. I need to execute it in background and also to remove terminal dependency. Thanks In advance. 116@434 (7 Replies)
Discussion started by: 116@434
7 Replies

2. Shell Programming and Scripting

How can put a background process to the foreground

Hi, guys: I am working on my own shell using c. When I put a process into the background, how can I put it back to the foreground using tcsetpgrp? Thanks (3 Replies)
Discussion started by: tomlee
3 Replies

3. UNIX for Advanced & Expert Users

what is the diff b/w background and foreground process

What are all the difference between a Background and Foreground processes ?! A Background process does not have access to STDIN and OUT.. What else ? Is there any detailed description available somewhere ? (5 Replies)
Discussion started by: onequestion
5 Replies

4. Red Hat

Sometimes my xterm colors get inverted

I don't know exactly when or why, maybe running less or some command, my white text on a black background gets inverted and all the text looks like it is "selected", it is white background with black text. it is very annoying. I found this solution.;. export TERM=vt100 vi This... (0 Replies)
Discussion started by: srhadden
0 Replies

5. Shell Programming and Scripting

Background and Foreground of a process within a script

I'm not sure if it is even possible but I figured if it was someone here would know how to do it... I am running a script which starts a bunch of processes in the background but there is one process I would like to bring back to the foreground when complete. Unfortunately the process that I... (2 Replies)
Discussion started by: ctruhn
2 Replies

6. Shell Programming and Scripting

how to get background job to foreground

hi, i am just wondering that wen we give the following code we make a process run in background...can the viceversa be performed?i.e can this be made foreground again # sleep 75& 21751 # (4 Replies)
Discussion started by: sandilya
4 Replies

7. UNIX for Dummies Questions & Answers

set background/foreground color in .profile

I am using a telnet session (VT100) and need to modify my .profile so that it will set the color of the telnet session. I am not using Xterm (ie: can't use .Xdefaults). I am able to change the colors via menu's but need to preset in .profile. Is this possible??? Can't find anything at all on how... (3 Replies)
Discussion started by: dvella
3 Replies

8. Linux

xterm font colors - configuration question?

When I telnet (ssh) over to my Fedora system, I find the colors horrible. For instance, regular files are white text, which is fine, but directories show up as dark blue which is virtually invisible against the black background). Additionally, when using vi, I find the colors great doing perl... (3 Replies)
Discussion started by: ripley
3 Replies

9. UNIX for Dummies Questions & Answers

problems with ctrl-z, to switch foreground, background

my shell is /sbin/sh. i added stty susp '^Z' with the intention of being able to switch between foreground and background. but the result was strange. i had 2 servers. one is sun the os is 8 and the other is hpux v11. both of them had the same shell. but on hpux, it works perfectly fine while... (9 Replies)
Discussion started by: yls177
9 Replies

10. UNIX Desktop Questions & Answers

xterm colors

I'm a new user to unix and I want to be able to pick and choose different xterm colors via 3rd botton menu. I'm currently pico'd into my .fvwm2rc file and this is what I have under my bottons: Please advise ############ # Button 1 #... (2 Replies)
Discussion started by: blica777
2 Replies
Login or Register to Ask a Question