Login Register






Make your terminal greet you filter_list
Author
Message
Make your terminal greet you #1
This is simple, but effective. I just got the idea, because of @MrGeek's terminal thread.
You can make your terminal greet you the right way depending on the daytime plus saying a random quote for your amusal. It might look like this:

[Image: 2sxoxytn.png]

Or this:

[Image: 3dzysp5f.png]

And this is how you do it:

1. Install cowsay and fortune

If you are on Ubuntu:

Code:
sudo apt-get install cowsay sudo apt-get install fortune-mod

2. Put the following python script into your home


Open a text editor of your choice, copy my code into it and save it as welcome.py

Code:
import getpass from datetime import datetime from subprocess import call, Popen, PIPE user = getpass.getuser() hour = datetime.time(datetime.now()).hour if hour >= 22: str = "Sleep Well, " + user + "!" elif hour >= 18: str = "Good Evening, " + user + "!" elif hour >= 14: str = "Good Afternoon, " + user + "!" elif hour >= 12: str = "Enjoy Your Meal, " + user + "!" else: str = "Good Morning, " + user + "!" fortune = Popen(["fortune"], stdout=PIPE).communicate()[0] call(["cowsay", "-f", "tux", str + "\n\n" + fortune])

3. Edit the .bashrc

Add the following line:

Code:
python welcome.py

Now everytime you open your terminal you get an appropriate greeting.

4. Customizing

If you want another ascii picture than tux, you have to edit the last line of the python code and replace tux with i.e.: dragon, cock, snowman, elephant, milk, cow, pony, kiss, koala, gnu, skeleton, ren, moose, sheep ... (see /usr/share/cowsay/cows for the files available)
I.e. to have the dragon you will have to write:

Code:
call(["cowsay", "-f", "dragon", str + "\n\n" + fortune])

Alternatively you can use the randomized welcome.py (shows a random ascii, if you don't like a picture, add it to the blacklist):

Code:
import getpass import random from datetime import datetime from subprocess import call, Popen, PIPE from os import listdir from os.path import isfile, join blacklist = ["beavis.zen", "ghostbusters", "elephant-in-snake", "unipony", "daemon", "sodomized-sheep", "eyes", "kosh", "calvin", "gnu", "kiss", "turkey", "turtle", "pony", "mutilated", "head-in"] #put your unwanted cows in here cowpath = "/usr/share/cowsay/cows" cows = [ f[:-4] for f in listdir(cowpath) if isfile(join(cowpath,f)) and f.endswith(".cow") and f[:-4] not in blacklist ] user = getpass.getuser() hour = datetime.time(datetime.now()).hour random_cow = random.choice(cows) say_or_think = random.choice(["say", "think"]) if hour >= 22: str = "Sleep Well, " + user + "!" elif hour >= 18: str = "Good Evening, " + user + "!" elif hour >= 14: str = "Good Afternoon, " + user + "!" elif hour >= 12: str = "Enjoy Your Meal, " + user + "!" else: str = "Good Morning, " + user + "!" fortune = Popen(["fortune"], stdout=PIPE).communicate()[0] call(["cow" + say_or_think, "-f", random_cow, str + "\n\n" + fortune])
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

Make your terminal greet you #2
This is simple, but effective. I just got the idea, because of @MrGeek's terminal thread.
You can make your terminal greet you the right way depending on the daytime plus saying a random quote for your amusal. It might look like this:

[Image: 2sxoxytn.png]

Or this:

[Image: 3dzysp5f.png]

And this is how you do it:

1. Install cowsay and fortune

If you are on Ubuntu:

Code:
sudo apt-get install cowsay sudo apt-get install fortune-mod

2. Put the following python script into your home


Open a text editor of your choice, copy my code into it and save it as welcome.py

Code:
import getpass from datetime import datetime from subprocess import call, Popen, PIPE user = getpass.getuser() hour = datetime.time(datetime.now()).hour if hour >= 22: str = "Sleep Well, " + user + "!" elif hour >= 18: str = "Good Evening, " + user + "!" elif hour >= 14: str = "Good Afternoon, " + user + "!" elif hour >= 12: str = "Enjoy Your Meal, " + user + "!" else: str = "Good Morning, " + user + "!" fortune = Popen(["fortune"], stdout=PIPE).communicate()[0] call(["cowsay", "-f", "tux", str + "\n\n" + fortune])

3. Edit the .bashrc

Add the following line:

Code:
python welcome.py

Now everytime you open your terminal you get an appropriate greeting.

4. Customizing

If you want another ascii picture than tux, you have to edit the last line of the python code and replace tux with i.e.: dragon, cock, snowman, elephant, milk, cow, pony, kiss, koala, gnu, skeleton, ren, moose, sheep ... (see /usr/share/cowsay/cows for the files available)
I.e. to have the dragon you will have to write:

Code:
call(["cowsay", "-f", "dragon", str + "\n\n" + fortune])

Alternatively you can use the randomized welcome.py (shows a random ascii, if you don't like a picture, add it to the blacklist):

Code:
import getpass import random from datetime import datetime from subprocess import call, Popen, PIPE from os import listdir from os.path import isfile, join blacklist = ["beavis.zen", "ghostbusters", "elephant-in-snake", "unipony", "daemon", "sodomized-sheep", "eyes", "kosh", "calvin", "gnu", "kiss", "turkey", "turtle", "pony", "mutilated", "head-in"] #put your unwanted cows in here cowpath = "/usr/share/cowsay/cows" cows = [ f[:-4] for f in listdir(cowpath) if isfile(join(cowpath,f)) and f.endswith(".cow") and f[:-4] not in blacklist ] user = getpass.getuser() hour = datetime.time(datetime.now()).hour random_cow = random.choice(cows) say_or_think = random.choice(["say", "think"]) if hour >= 22: str = "Sleep Well, " + user + "!" elif hour >= 18: str = "Good Evening, " + user + "!" elif hour >= 14: str = "Good Afternoon, " + user + "!" elif hour >= 12: str = "Enjoy Your Meal, " + user + "!" else: str = "Good Morning, " + user + "!" fortune = Popen(["fortune"], stdout=PIPE).communicate()[0] call(["cow" + say_or_think, "-f", random_cow, str + "\n\n" + fortune])
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Make your terminal greet you #3
I use ubuntu I'll try it out. Thank you Confusedmiling:

One more thing Can we use ASCII art that we make by ourselves ?
[Image: OilyCostlyEwe.gif]

Reply

RE: Make your terminal greet you #4
I use ubuntu I'll try it out. Thank you Confusedmiling:

One more thing Can we use ASCII art that we make by ourselves ?
[Image: OilyCostlyEwe.gif]

Reply

RE: Make your terminal greet you #5
If you edit it this way, yes.
Either create the ascii art within the python file or add a new cowsay file.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Make your terminal greet you #6
If you edit it this way, yes.
Either create the ascii art within the python file or add a new cowsay file.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: Make your terminal greet you #7
I got the following error

Code:
File ".bashgreet", line 11 SyntaxError: Non-ASCII character '\xc2' in file .bashgreet on line 11, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Update: Fixed it. Had to re-indent all "str =" lines Wink

Another update: Sorry, forgot to say thanks for this @Deque Smile So, thanks! I like nerdy stuff like this Smile
"SQL Injection-a-holic"

Twitter | Security Sucks | My Blog

Reply

RE: Make your terminal greet you #8
I got the following error

Code:
File ".bashgreet", line 11 SyntaxError: Non-ASCII character '\xc2' in file .bashgreet on line 11, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Update: Fixed it. Had to re-indent all "str =" lines Wink

Another update: Sorry, forgot to say thanks for this @Deque Smile So, thanks! I like nerdy stuff like this Smile
"SQL Injection-a-holic"

Twitter | Security Sucks | My Blog

Reply

RE: Make your terminal greet you #9
I used to love how Clement Lefebvre used to incorporate a similar method into the default terminal setup of LinuxMint in the bygone days of Gnome2.

Reply

RE: Make your terminal greet you #10
I used to love how Clement Lefebvre used to incorporate a similar method into the default terminal setup of LinuxMint in the bygone days of Gnome2.

Reply