random colour xterm alias


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting random colour xterm alias
# 1  
Old 01-09-2009
random colour xterm alias

I used to have this but do not know where it went - a script or an alias that:

opens a new xterm window with a random background colour.

I have this off "the internets" :
alias xterm1="xterm ... -bg \#* printf '%02x%02x%02x' {repeat 3 times $((RANDOM%128+128))}` &"

this gives me an alias: xterm1='xterm .. -bg \#8beaf7 &'
..which kind of works, but it's not elegant and it means that the window colouring is only random recursively.

any of you have a "better" version of this?
# 2  
Old 01-09-2009

Put this in a script or a function:

Code:
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" &


Last edited by cfajohnson; 01-09-2009 at 03:23 PM..
This User Gave Thanks to cfajohnson For This Post:
# 3  
Old 01-12-2009
works like a charm - thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom. I create a named pipe then: dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024 but when I cat a file to the fifo that's 1024 random bytes: cat randomfile.txt >... (7 Replies)
Discussion started by: Devyn
7 Replies

2. Shell Programming and Scripting

sed colour change

Hi, I am trying to write a script which will email a backup report from the server, The contents of the email will be: ---------------------- ---- -- ---- ----- ---- ------- ---- ------- ------- | | | | |Chnge|Wkng| | | | | | ... (6 Replies)
Discussion started by: Bdoydie
6 Replies

3. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

4. Ubuntu

expect script for random password and random commands

Hi I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue: I want expect script for random passwords and random commands generation. please can anyone help me? Many Thanks in advance (0 Replies)
Discussion started by: vanid
0 Replies

5. Programming

Cshell help with change colour in print

i want to ask how to change the colour of prompt message from use? and also how to change colour in printing........ i want to change it as blue colour and red colour, but i found many website still don't know how to do. how's the command is wrote? thz really!! (1 Reply)
Discussion started by: wendy1089
1 Replies

6. HP-UX

hpux top colour

Hello, is there some way to change b/w colour of top command output in hpux B.11.31 ? (1 Reply)
Discussion started by: tonijel
1 Replies

7. Shell Programming and Scripting

ksh, font colour

hi all, how do i change the colour of text if i am using printf ?? in my script i am printing out response times from the server and i wanted to print out the max response time in red. ta. (1 Reply)
Discussion started by: cesarNZ
1 Replies

8. Shell Programming and Scripting

#!/bin/sh script is in white colour

Hello friends. I realize that my question is naive, but I really want to know, why one of my scripts is in white colour (I mean letters in the body are white) while 3 residuary are multicoloured. I'm asking because I have a little problem with this particular script. It's absolutely the same as... (1 Reply)
Discussion started by: MarGur
1 Replies

9. Shell Programming and Scripting

VT100 terminal and colour

Good day all I am looking for a way to change colours in a text file that get tailed. I have tried using tput, however this does not seem to work. terminal type is using putty and vt100 emulation. Any ideas. :rolleyes: Thanks J (6 Replies)
Discussion started by: jhansrod
6 Replies
Login or Register to Ask a Question