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>!)
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.
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.
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>!
)In browser console? How ?
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.
I am asking about.. How to run that program every time we open a console ?
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
.Ok.. Thank you💙