.cshrc trickery, need help

lipbone

Registered
I'm trying to get terminal to greet me with Good Morning, Good Afternoon, and Good Night (even maybe Happy Birthday!). How can I do this? Is it possible. I know it must be some sort of if-then statement, but I don't know much about terminal commands.

Thanks.
 
Would it have to tell you that upon login or whenever you are connected and it's suddenly afternoon?

dani++
 
Hmmmm. Didn't think about that. My initial thought was to have it greet me upon login. In fact, that's all I really need, now that I think about it.
 
Add this to your .tcshrc:

Code:
set hour = `date '+%H'`

if( $hour < 12 ) then
   echo "Good morning"
else if( $hour < 18 ) then
   echo "Good afternoon"
else if( $hour < 20 ) then
   echo "Good evening"
else
   echo "Good night"
endif

Season to taste.
 
Thank you! how does the +%H isolate the hour? I ask so that I can also isolate the date and have it wish me a happy birthday too!
 
blb, thats freakin' awsome!

Let me now share with you all something blb and I worked on in irc one day...
Its for .bashrc, but I think its tcsh-compatable. Here it is:
Code:
alias why="if [ \$RANDOM -gt 16384 ]; then echo 'because'; else echo 'why not'; fi"

What this does is alternate the shell's reply to 'why'. It will say "why not" or "because" based on $RANDOM being odd or even, I think.

If you were a mean *mean* sysadmin, you could alias something like 'ls' to this in everyone's shell init script, just for April Fools :D
 
Now, I want to make the prompt, and only the prompt, a different color from the rest of the text. Is this possible? I couldn't determine anything from the other color posts. I'm learning though.

TIA
 
Originally posted by kilowatt

If you were a mean *mean* sysadmin, you could alias something like 'ls' to this in everyone's shell init script, just for April Fools :D
[/B]

BOFHs of the world, UNITE!

-alex.
 
Getting a specific date means having a quick look at man strftime which is where the formats are documented; if your birthday is April first, you could do something like

Code:
set today = `date '+%m%d'`

if( $today == '0401' ) then
   banner happy birthday
endif

just be sure to use a four digit code to test against $today as each %m and %d return two digit numbers (zero-prefixed if necessary).

Oh, OmniWeb needs a vi-editing mode; I hate hitting Esc and having it just beep at me...
 
Thank you all very much. My terminal experience has improved! It's very cool to see how immediate the terminal is. I guess that's hard to translate to anyone who doesn't use it.
 
Back
Top