Ads 468x60px

Saturday, August 6, 2011

Customize The Linux Terminal

The Linux Terminal is powerful, but sometimes can be dull and boring. Here are some of my customizations that make the Terminal a little more attractive. All of these can be done by editing the .bashrc file in the Home folder. All these are not for Linux Mint by the way, as Linux Mint already has these customizations.

Add Some Color:

Wanna display the current directory and your username in bash? But with some colors? Then just add the following in the .bashrc

# Colors
PS1='\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\W\[\033[00m\]\[\e[1;32m\]\$\[\e[m\] '

Well, you can

Display a Fortune:

You can display random quotes in bash. First install fortune-mod.

For Ubuntu,
sudo apt-get install fortune-mod

For Fedora
su -
yum install fortune-mod

Now add the following to the .bashrc

fortune -s



Here is my Terminal(Konsole) in KDE.

If you want to display animals as above, first install cowsay,

For Ubuntu,
sudo apt-get install cowsay

For Fedora
su -
yum install cowsay

Then add,

fortune -s | cowsay -n

In stead of

fortune -s

To randomize cows, you can replace it with

# Check for interactive terminal (should not produce output otherwise).
if [ "$PS1" ]; then
# Set location of cow files.
cowdir="/usr/share/cowsay"

# Create an array from the files in our $cowdir.
cows=($cowdir/*)

# Randomly select a cow from our cows
# (${#myarr[*]} == num items in array, RANDOM == random number).
mycow="${cows[RANDOM % ${#cows[*]}]}"

# Create an array of possible cow actions (think or say).
cowactions=("cowsay" "cowthink")

# Randomly select an action.
myaction="${cowactions[RANDOM % ${#cowactions[*]}]}"

# Call fortune and pass the results to cowthink/cowsay with our chosen cow.
fortune | $myaction -n -f "`basename ${mycow}`"
fi

You can refer this wiki for further details

No comments:

Post a Comment