04
Jul
09

Futurama ascii with Slashdot header quotes in your terminal

Fry, now with quotes!

Fry, now with quotes!

I know you want this. And here’s how. The tutorial even noobs can follow.

There is an easter-egg in the application apt. Have a look for yourself:

Code:
apt-get moo

If you want to have a silly cow greet you when you open up a terminal window, by all means put this command at the top of your bashrc. But there is a better way of doing it. Install this application:

Code:
sudo apt-get install cowsay

Now try running it with something you want to say,

Code:
cowsay Hello! I am awesome!
Code:
 ______________________
< Hello! I am awesome! >
 ----------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Now by using the -f option, you can choose other characters to greet you. Try out some of these:

Code:
cowsay -f tux "Hello I am groovy!"
cowsay -f sheep "Baaaaaaaa"
cowsay -f dragon "Rarr!"

To see all of the available options, run

Code:
cowsay -l

Wouldn’t it be great if you could have these characters say something different each time? Well, why the hell not, huh?

First make sure you have these packages:

Code:
sudo apt-get install fortunes fortunes-off

Now try running

Code:
fortune

to see a quote. Fortune has options too.

Code:
fortune -s   # for short quotes
fortune -l   # for long quotes
fortune -o   # for offensive quotes

You can combine those options a little, too. So for short, offensive quotes, go ahead and run

Code:
fortune -so

So how about combining these two awesome things? Go ahead and run this:

Code:
cowsay -f tux "$(fortune)"
Code:
 ____________________________________
/ To thine own self be true. (If not \
\ that, at least make some money.)   /
 ------------------------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

Now we’re really getting somewhere! Combine some of the techniques we already know and we can do quite a few cool things. Let’s try a few more commands!

Code:
cowsay -f dragon "Hello, the time is $(date "+%k:%M, on %A, %d of %B, %Y.")"
cowsay -f tux "$(fortune -so)"

Well, now we have lots of cool things for a fancy welcoming prompt. Let’s try and incorporate the old geek-stable, Slashdot html-headers! You’ll need an internet connection for this stuff, and faith in Slashdot’s servers not exploding for some reason. First of all let’s have a look at them:

Code:
curl -Is slashdot.org

If you look closely you’ll see a random Futurama quote in there. Brilliant! We should use those for our greeting. And it turns out we can, by running the following command:

Code:
curl -Is slashdot.org | egrep '^X-(F|B|L)' | sed 's/^..//'

which strips all the information except for the quote. Have a look at the “(F|B|L)” section. This part of the command dictates whether you receive a Fry, Bender, or Leela quote. At the moment it will get any of them, so for individual characters, you must run

Code:
curl -Is slashdot.org | egrep '^X-(F)' | sed 's/^..//'  # for Fry
curl -Is slashdot.org | egrep '^X-(B)' | sed 's/^..//'  # for Bender
curl -Is slashdot.org | egrep '^X-(L)' | sed 's/^..//'  # for Leela

Wouldn’t it be awesome if we could use the ascii art from the cowsay application for these quotes? We could, but it might look a little odd:

Code:
cowsay -f tux "$(curl -Is slashdot.org | egrep '^X-(F|B|L)' | sed 's/^..//')"
 ____________________________________
< Fry: I'll be whatever I wanna do.  >
 ------------------------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

We’re going to need some ascii art for Fry, Bender and Leela. Luckily for you, I’m going to give you some [gotfuturama.com]. All you need to know is that cowsay uses cowfiles, which are stored in “/usr/share/cowsay/cows/”

For Fry,

Code:
gksudo gedit /usr/share/cowsay/cows/fry.cow

And paste the following into it:

Code:
the_cow = <<EOC;
   $thoughts
    $thoughts
             u
      .  x!X
    ."X M~~>
   d~~XX~~~k    .u.xZ `\ \ "%
  d~~~M!~~~?..+"~~~~~?:  "    h
 '~~~~~~~~~~~~~~~~~~~~~?      `
 4~~~~~~~~~~~~~~~~~~~~~~>     '
 ':~~~~~~~~~~(X+"" X~~~~>    xHL
  %~~~~~(X="      'X"!~~% :RMMMRMRs
   ^"*f`          ' (~~~~~MMMMMMMMMMMx
     f     /`   %   !~~~~~MMMMMMMMMMMMMc
     F    ?      '  !~~~~~!MMMMMMMMMMMMMM.
    ' .  :": "   :  !X""(~~?MMMMMMMMMMMMMMh
    'x  .~  ^-+="   ? "f4!*  #MMMMMMMMMMMMMM.
     /"               .."     `MMMMMMMMMMMMMM
     h ..             '         #MMMMMMMMMMMM
     f                '          (MMMMMMMMMMM
   :         .:=""     >       dMMMMMMMMMMMMM
   "+mm+=~("           RR     HMMMMMMMMMMMMM"
           %          (MMNmHHMMMMMMMMMMMMMMF
          uR5         dMMMMMMMMMMMMMMMMMMMF
        dMRMM>       dMMMMMMMMMMMMMMMMMMMF
       RMHMMMF=x..=" RMRMMMMMMMMMMMMMMMMF
      MMMMMMM       'MMMMMMMMMMMMMMMMMMF
     dMMRMMMK       'MMMMMMMMMMMMMMMMM"
     RMMRMMME       3MMMMMMMMMMMMMMMM
    XMMMMMMM>       9MMMMMMMMMMMMMMM~
   'MMMMMMMM>       9MMMMMMMMMMMMMMF
   tMMMMMMMM        9MMMMMMMMMMMMMM
   MMMMMMMMM        9MMMMMMMMMMMMMM
  'MMMMRMMMM        9MMMMMMMMMMMMM9
EOC

For Bender,

Code:
gksudo gedit /usr/share/cowsay/cows/bender.cow

And paste the following:

Code:
$the_cow = <<EOC;
   $thoughts
    $thoughts
     ( )
      H
      H
     _H_
  .-'-.-'-.
 /         $thoughts
|           |
|   .-------'._
|  / /  '.' '. $thoughts
|  $thoughts $thoughts @   @ / /
|   '---------'
|    _______|
|  .'-+-+-+|
|  '.-+-+-+|
|    """""" |
'-.__   __.-'
     """
EOC

For Leela,

Code:
gksudo /usr/share/cowsay/cows/leela.cow

And paste the following:

Code:
$the_cow = <<EOC;
             $thoughts
              $thoughts

                    '#%n.
            ..++!%+:/X!!?:              .....
              "X!!!!!!!!!!?:       .+?!!!!!!!!!?h.
              X!!!!!!!!!!!!!k    n!!!!!!!!!!!!!!!!?:
             !!!!!!!!!!!!!!!!tMMMM!!!!!!!!!!!!!!!!!!?:
            X!!!!!!!!!!!!!!!!!5MMM``""%X!!!!!!!!!!!T4XL
            !!!!!!!!!X*")!!!!!!!?L       %X!!!!!!!!!k `
           '!!!!!!X!`   !!XX!!!!!!L       'X!!!!!!!!!>
           'X!!!!M`    '" X!!!!!!!X        !!!!!!!!!!X
            X!!!f^~('>   X!!!!!!!!!        '!!!!!!!!!X
            X!!X     `.  X!!!!!!!!f        '!!!!!!!!!!
            !Xf  O    '  '!!!!!!X"         '!!!!!!!!!X
           "`f-.     :~  MX*t!X"           X!!!!!!!!!>
             >.         W! ~!             '!!!!!!!!!X
            :`             ':             X!!!!!!!!!!
            ~ ^`          '              '!!!!!!!!!X
            `~~~~~~~~     !              X!!!!!!!!!X
                `~~~      !             '!!!!!!!!!!>
                  >       !             (!!!!!!!!!X
                          !             !!!!!!!!!!X
                  >       '             '!!!!!!!!!!
                .:         /:`^-.        X!!!!!!!!!>
           /`  ~/         /(     `:       X!!!X!!!!!:
         /   : f         f'        !       `XX!M!!!!!%
        ~   / ~        :  >         4            "*!!!*
       ~   ~ '        ~   >          :
EOC

So now go ahead and try out your skills, run them to see if they work:

Code:
cowsay -f fry "$(curl -Is slashdot.org | egrep '^X-(F)' | sed 's/^..//')"
cowsay -f bender "$(curl -Is slashdot.org | egrep '^X-(B)' | sed 's/^..//')"
cowsay -f leela "$(curl -Is slashdot.org | egrep '^X-(L)' | sed 's/^..//')"

Now you may have noticed that the quotes don’t always come through. That’s mainly because there is only ever one quote in the headers at any one time. Searching for a Leela quote when there is only a Bender quote available will fail! Luckily, there is a way around this. What we need to do is search the headers for the quote, and then depending on whose quote it is, bring up the cowsay application accordingly. Well lucky for you I’ve already done it for you. Paste this code at the top of your bashrc:

Code:
function futurama() { wee=$(curl -Is slashdot.org | egrep '^X-(F|B|L)' | sed 's/^..//'); if [[ $wee = "Fry"* ]]; then cowsay -f fry $(echo $wee | sed 's/^Fry: //'); fi; if [[ $wee = "Ben"* ]]; then cowsay -f bender $(echo $wee | sed 's/^Bender: //'); fi; if [[ $wee = "Lee"* ]]; then cowsay -f leela $(echo $wee | sed 's/^Leela: //'); fi; }

Now the quotes match. Save your bashrc or zshrc file and close. Now every time you’re in the mood for your Futurama fix, just fire up that command.

So you know how to have a random quote greet you. And you know how to have a funny ascii character greet you. Wouldn’t it be great if you could have both? Well you can!

Code:
cowsay -f tux "$(fortune)"
Code:
 ____________________________________
/ To thine own self be true. (If not \
\ that, at least make some money.)   /
 ------------------------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

Now we’re really getting somewhere! Combine some of the techniques we already know and we can do quite a few cool things. Let’s try a few more commands!

Code:
cowsay -f dragon "Hello, the time is $(date "+%k:%M, on %A, %d of %B, %Y.")"
cowsay -f tux "$(fortune -so)"

Pretty cool. Maybe you would like one of these, hrmm?

Advertisements

9 Responses to “Futurama ascii with Slashdot header quotes in your terminal”


  1. 30 June, 2011 at 2:59 pm

    hi it’s not working with my egrep. i think it is a syntactical error, but i dunno.

  2. 27 October, 2012 at 1:51 pm

    I absolutely love your blog and find a lot of your post’s to be exactly what I’m looking for.
    Would you offer guest writers to write content for you?
    I wouldn’t mind composing a post or elaborating on a few of the subjects you write with regards to here. Again, awesome weblog!

  3. 13 April, 2013 at 5:19 am

    Thanks for your marvelous posting! I really enjoyed
    reading it, you happen to be a great author.I will be sure to bookmark
    your blog and may come back down the road. I want to encourage continue your great writing, have a nice holiday weekend!

  4. 10 July, 2013 at 4:57 pm

    Hi! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in trading links or maybe guest writing a blog article or vice-versa?
    My website addresses a lot of the same subjects as yours and I believe we could greatly benefit from each other.
    If you happen to be interested feel free to shoot me an email.

    I look forward to hearing from you! Fantastic blog by the way!

  5. 25 July, 2013 at 10:00 am

    Hurrah, that’s what I was searching for, what a stuff! present here at this website, thanks admin of this web page.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


July 2009
M T W T F S S
    Aug »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Stuff goes here

Hijack this blog

You want to use something from this blag? What the hell is wrong with you? Do you want to fail at life? If you reuse the crap I post here, people will say, "Wow, I never knew anybody could be so ignorant!" Then they will go and find a weapon to beat you with. That's right. There's your god-damned copyright notice. You really care about that shit? Fine. Take it, copy it, pretend it's your own work. Do whatever the hell you want with it, I don't care.

Blog Stats

  • 13,560 people hate me.

%d bloggers like this: