Home Command line utilities Display Random Quotes From Commandline In Linux

Display Random Quotes From Commandline In Linux

By sk
Published: Last Updated on 16.9K views

Working from commandline in Linux is fun. We can do anything from Terminal, even motivate ourselves too. There are two simple bash/zsh shell scripts to display some random quotes from popular authors, and leaders on your Terminal. These scripts will work on any system that supports bash or zsh. In this brief guide, we will discuss how to install 'motivate' and 'fortune' programs to display random quotes from commandline in Linux.

Install Motivate script in Linux

The motivate program is highly influenced by popular Linux command 'fortune' which displays random poignant, inspirational, motivational phrases and quotes in Terminal.

You need to install the following prerequisites before using 'motivate' command.

  • git
  • python3

The above two applications are available on the default repositories of most modern Linux operating systems.

For example, to install git and python 3 on Arch Linux, run:

$ sudo pacman -S git python3

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install git python3

On RHEL, Fedora, CentOS:

$ sudo yum install git pythin3

On suse, openSUSE:

$ sudo zypper install git pythin3

Once you have installed above prerequisites, git clone the 'motivate' repository using command:

$ git clone https://github.com/mubaris/motivate.git

Sample output would be:

Cloning into 'motivate'...
remote: Enumerating objects: 1356, done.
remote: Total 1356 (delta 0), reused 0 (delta 0), pack-reused 1356
Receiving objects: 100% (1356/1356), 776.25 KiB | 812.00 KiB/s, done.
Resolving deltas: 100% (705/705), done.

The above command will clone the contents of 'motivate' in a directory called 'motivate' in your current working directory. Go to the 'motivate' directory:

$ cd motivate/motivate

Compile and install 'motivate' program as shown below.

$ sudo ./install.sh

Run the following command to take effect the changes.

$ source ~/.bashrc

If your shell is Zsh, just replace "~/.bashrc" with "~/.zshrc" in the above command.

Now, you can call the motivate program to display quotes using command:

$ motivate

If you have no root privilege, you can still install it as shown below.

$ git clone https://github.com/mubaris/motivate.git
$ cd motivate
$ ln -s $PWD/motivate/motivate.py moti
$ ln -s $PWD/dummy.sh mmoti
$ echo 'export PATH=$PWD:$PATH' >> ~/.bashrc
$ source ~/.bashrc

And then run the following command to display quotes.

$ moti

Motivate program has been installed now. Now, let us have some fun from Terminal.

Display random quotes using Motivate shell script

To display any random quotes, just run the following command from your Terminal.

$ motivate

Or,

$ moti

You will now be greeted with a random quote.

"You don't have to be great to start, but you have to start to be great."
        --Zig Ziglar

Keep running this command to get more quotes. Here is some quotes displayed by 'motivate' command in Ubuntu server .

Display Random Quotes From Commandline Using Motivate program

Display Random Quotes From Commandline Using Motivate program

To update the database, clone the motivate git repository:

$ git clone https://github.com/mubaris/motivate.git

Then, go to the motivate directory:

$ cd motivate

And, update it using command:

$ ./UPDATE

Display random quotes Using fortune command

Like said already, Motivate program is highly influenced by the 'fortune' command. You can display random quotes, funny phrases, and popular adages using 'fortune' command too.

To install it on RPM based systems, run:

$ sudo yum install fortune

On DEB based systems:

$ sudo apt-get install fortune

Once you installed it, run 'fortune' on your Terminal to get random quotes and thoughts of popular people.

$ fortune

Here are some fortunes from my Ubuntu system.

Display Random Quotes From Commandline Using Fortune program

Display Random Quotes From Commandline Using Fortune program

Automatically display quotes when you open Terminal

The motivate and fortune programs can automatically display quotes, funny sayings, adages whenever you open Terminal application. To do so, you need to add the motivate or  fortune command to the profile configuration file of your preferred shell:

If you're on BASH, open the bashrc file:

$ nano ~/.bashrc

Add the following lines for fortune command:

#!/bin/bash
# ~/.bashrc
fortune

For motivate command, add the following lines:

#!/bin/bash
# ~/.bashrc
motivate

Save and close the file. And type the following commands to take effect the changes.

$ source ~/.bashrc

From now on, you will be greeted with a quote whenever you open the Terminal.

Stay motivated!

Resources:

You May Also Like

1 comment

Max deWinter January 29, 2021 - 3:14 am

Youve got to be kidding. sudo install which updates your bashrc? Forget it.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More