Useful bashrc scripts

When you first open a linux terminal, it will read a file called .bashrc (the dot at the beginning means it's a hidden file), located in your home directory.  In so many words, this file tells the terminal emulator how to behave, what to display, and how to react to user input.

The following is a collection of scripts I've gathered over the years.  Some of these come from ubuntu forums, debian user forums, linuxquestions, and some are my own.

I usually find myself sharing these with others, all the time, so I'll just keep them here.

Define a few Colours
This is useful if you don't know all these little alphanumerical codes. It's a lot easier to remember "${CYAN}" than '\e[0;36m'. This code can be inserted right at the beginning of your bashrc file.

BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
LIGHTGRAY='\e[0;37m'
DARKGRAY='\e[1;30m'
LIGHTBLUE='\e[1;34m'
LIGHTGREEN='\e[1;32m'
LIGHTCYAN='\e[1;36m'
LIGHTRED='\e[1;31m'
LIGHTPURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
NC='\e[0m' # No Color


Show a greeting
If you want your terminal to tell you something as soon as you open it, you can.
echo -ne "${YELLOW}" "Hello, $USER. today is, "; date
echo -ne "${CYAN}";
echo -ne "${LIGHTCYAN}Sysinfo:";uptime ;echo ""
echo -ne "${LIGHTGREEN}"; uname -a ;


Extract things
I'm pretty sure this one came right out of ubuntuforums. I've been a member since 2007, and I've posted quite a lot of stuff, so I can't recall exactly. This is incredibly useful, if you're lazy and can't remember all the little flags and parameters for every single compression format. It's easier to remember "extract file.tar.gz" than "tar xvzf file.tar.gz." Even if you do it all the time. It's just easier to type. :)
extract () {
     if [ -f $1 ] ; then
         case $1 in
             *.tar.bz2)   tar xjf $1        ;;
             *.tar.gz)    tar xzf $1     ;;
             *.bz2)       bunzip2 $1       ;;
             *.rar)       rar x $1     ;;
             *.gz)        gunzip $1     ;;
             *.tar)       tar xf $1        ;;
             *.tbz2)      tar xjf $1      ;;
             *.tgz)       tar xzf $1       ;;
             *.zip)       unzip $1     ;;
             *.Z)         uncompress $1  ;;
             *.7z)        7z x $1    ;;
             *)           echo "'$1' cannot be extracted via extract()" ;;
         esac
     else
         echo "'$1' is not a valid file"
     fi
}


Clock
From my days as a console freak. DVTM and GNU screen were my killer combination. This little script gives you a nice digital clock.

clock () 
{ 
while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done 
}


RSS Feed
I would use this to get the latest cutewithchris updates. Too bad my lord has retired from the interwebz. This script can be used to get RSS feeds on your terminal.
rssupdate ()

{
rsstail -d -c -H -u http://url.of.your/desired/rss/feed
}