Random colors and jokes in the shell/terminal

9,193

Solution 1

Running a ruby script on every login doesn't sound like my idea of a good time.
But if it's colours you want you won't be disappointed by lolcat https://github.com/busyloop/lolcat

DISCLAIMER: I have since set this up on my SSH banners throughout my home cluster :)
Looks great with some text piped in from figlet

lolcat

Solution 2

Text-mode graphics + jokes can be implemented using installing ponysay + fortune.

The ponysay package by default displays a string picking up a random poney.

Then for basic use, you do:

fortune | ponysay

or:

fortune | ponythink

From ArchWiki:

For full 256-colored cowsay-like art use ponysay (version 3.0 has 422 ponies). The syntax is $ ponysay message to say something and ponysay -l for a complete list of ponies. To select a pony to display, run $ ponysay --pony x "message", where x is a pony. To create more ponies use util-say-gitAUR and store them in ~/.local/share/ponysay/ponies and ~/.local/share/ponysay/ttyponies/ for desktop and TTY, respectively.

There is a fork here in github, which has link of packages for other distributions. https://github.com/erkin/ponysay

To install it:

git clone https://github.com/erkin/ponysay
cd ponysay
./setup.py build --freedom=partial
./setup.py install --freedom=partial

As for fortune itself, from man fortune:

NAME fortune - print a random, hopefully interesting, adage

DESCRIPTION When fortune is run with no arguments it prints out a random epigram. Epigrams are divided into several categories, where each category is sub-divided into those which are potentially offensive and those which are not.

The user may specify alternate sayings. You can specify a specific file, a directory which contains one or more files, or the special word all which says to use all the standard databases.

As a side note, if in Debian you install the package fortunes-debian-hints, besides jokes you also get the occasional technical advice about Debian. We have here a server for student training, and I installed this there coupled with fortune-mod+fortunes-debian-hints for sending technical fortunes at every login.

As for the packages with fortune data files, you even have got fortune data files in several tongues besides English, and you can easily put together your own set of jokes as the format is quite simple. Be particularly aware of fortunes-off in multi-user environments, as it can and will display sarcastic/non-political-correct jokes quite often.

ponies

4feet

Solution 3

Don't know about the colors, but to add a little humor to opening a terminal:

sudo apt-get install cowsay fortune

Add to your ~/.profile or ~/.bashrc (depending to the specific configuration, shell, and terminal emulator):

if [ -x /usr/games/cowsay ] &&  [ -x /usr/games/fortune ]; then
   /usr/games/fortune | /usr/games/cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
fi
  • fortune displays a pithy quotation chosen at random from those stored in /usr/share/games/fortunes/.
  • cowsay display ASCII art depicting some sort of animal with a speech bubble.

Solution 4

In order to change color you could use tput.

Something that i prefer to use to highlight a line on the shell is

echo "`tput setf 7``tput setb 4``tput bold`  SOMETHING TO HIGHLIGHT  `tput sgr0`"

List of tput color can be found here with examples

Solution 5

One more to way have fun with cowsay and fortune::

add below lines to your bashrc

ls -1 /usr/share/cowsay/cows/ | awk -F '.' '{print $1}' >  file
COWSA=`head   -$((${RANDOM} % \`wc -l < file\` + 1))  file | tail -1`
cowsay -f $COWSA `fortune`

This will give you random picture of cowsay with fortune quote. The first line is not relevant, you can just copy the names to a file(same file name as in second line) permanently and do without first line. Have fun !

Edit: Sorry, this was already mentioned in @AlexP anwser. Not deleting this as I used different concept to achieve this :)

Share:
9,193

Related videos on Youtube

Undermark5
Author by

Undermark5

Updated on September 18, 2022

Comments

  • Undermark5
    Undermark5 over 1 year

    I saw a person that while using their terminal, it output a joke and changed the colors and laughed at the user. It said something along the lines of leaking colors into the console since (year). I don't remember what it was, but I'd like to use it because the Kubuntu Konsole gets very boring after long hours of use, and I'd like to liven things up a bit. Any ideas on what it is/where I can get it?

    What I'm looking for is something that does it automatically -- without specific input from the user to run a script or command (or even a command run at startup). The thing I'm looking for changed the color themes of the shell at random intervals and joked about the color change. Perhaps it was just a different terminal program (I don't know if that is the right term) than Konsole that is built into Kubuntu.

    • Admin
      Admin over 7 years
      "Terminal codes" or "ANSI codes" is what you are looking for.
    • Admin
      Admin over 7 years
      You can also turn on sudo insults for a healthy dose of snark whenever you enter your password wrong.
  • Rui F Ribeiro
    Rui F Ribeiro over 7 years
    OMG!!! Ponies!!! LOL!!!
  • Reinstate Monica -- notmaynard
    Reinstate Monica -- notmaynard over 7 years
    This is also available in (at least) Ubuntu's repos with apt-get install lolcat. I also had to gem install lolcat.
  • EKons
    EKons over 7 years
    @jamesqf Yeah, you don't have 4 feet!
  • wizzwizz4
    wizzwizz4 over 7 years
    @jamesqf Many of them are from My Little Pony, apparently. Erm, not that I would know... He... he...
  • Undermark5
    Undermark5 over 7 years
    While this does have some of the things I was looking for, it is not what I am looking for, perhaps I should clarify the question.
  • muru
    muru almost 6 years
    You can test the exit status of command directly: if command -v ponysay >&-; then ...
  • Tom Hale
    Tom Hale almost 6 years
    @muru Know of any way to get rid of that final cat?