DEV Community

Discussion on: Make your console messages colorful

Collapse
 
hentaichan profile image
ヘンタイちゃん

Something I added a while back: Every time I open my console, the top line prints a random colorful greeting message. Fun exercise: make this message depending on the time of the day (Good morning, <username>!)

Collapse
 
rajasekharguptha profile image
Rajasekhar Guptha

In browser console? How ?

Collapse
 
thinkverse profile image
Kim Hallberg

Guessing you could use a two-dimensional array where the first is keys that match some time of day. And the sub-array for those keys would be the styles to apply at that time. 🤔

Then you would check the current time when the console executed the command, and use some algorithm to come up with a number corresponding to the first key.
You could probably divide the current time by the length of the time keys or check if a certain key is in the range of the current time but not greater than the next key.

Guessing that would work to an extend.

Thread Thread
 
rajasekharguptha profile image
Rajasekhar Guptha

I am asking about.. How to run that program every time we open a console ?

Thread Thread
 
hentaichan profile image
ヘンタイちゃん

Depends on your terminal, on Windows using PowerShell you can make these changes permanent by adding your code to the $PROFILE file, whereas on linux you'd need to make these changes in ~/.bashrc.

Thread Thread
 
rajasekharguptha profile image
Rajasekhar Guptha

Ok.. Thank you💙