Zack's Website

My Egotistic and Esoteric Website

Linux Bash Scripts

Bash/Linux Startup Scripts

Bash (/bin/bash) is the default shell that most Linux systems use.  It's got native scripting capability and by default will look at a user's directory and upon login attempt to run ".bashrc".  This is mine...

##############################################################
#            Zack's Home Bash Script (c) 1992-2011           #
##############################################################

# Read Default BASHRC file from /etc if found
if [ -f /etc/bashrc ]; then


   . /etc/bashrc
fi


 

#Add some of Zack's Paths Here
PATH=$PATH:$HOME/bin:$HOME/bin/mono/bin:/usr/lib/java/bin

BASH_ENV=$HOME/.bashrc

JAVA_HOME=/usr/lib/java


# Set the DISPLAY
if [ -z ${DISPLAY:=""} ]; then
    get_xserver
    if [[ -z ${XSERVER}  || ${XSERVER} == $(hostname) || \
      ${XSERVER} == "unix" ]]; then
        DISPLAY=":0.0"          # Display on local host.
    else
        DISPLAY=${XSERVER}:0.0  # Display on remote host.
    fi
fi

export DISPLAY





# Define some colors first:

red='\e[0;31m'
RED='\e[1;31m'
blue='\e[0;34m'
BLUE='\e[1;34m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m'              # No Color




#Setup Some Aliases
alias xterm='/usr/bin/xterm -bg black -fg green -cr orange +cm +dc -font -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* -geometry 150x40'
alias dir='ls -la'
alias path='echo -e ${PATH//:/\\n}'





echo -e "WELCOME TO ${CYAN}bart.zackburns.com${NC} - Home Office Development Machine"
echo -ne ""; uname -a;
echo -e "${CYAN}This is BASH ${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}"
echo -ne "Machine Uptime ";uptime;
echo -ne "Today is ";date;
echo -e ""; cal;
echo -e ""

if [ -x /usr/games/fortune ]; then
    /usr/games/fortune -s     # Makes our day a bit more fun.... :-)
fi
echo -e ""

# Shell Prompt
if [[ "${DISPLAY%%:0*}" != "" ]]; then  
    HILIT=${red}   # remote machine: prompt will be partly red
else
    HILIT=${cyan}  # local machine: prompt will be partly cyan
fi



function _exit()        # Function to run upon exit of shell.
{
    echo -e "${RED}Hasta la vista, baby${NC}"
    sleep 2
}
trap _exit EXIT

 

 

 

Which gives the following output...

 

WELCOME TO bart.zackburns.com - Home Office Development Machine
Linux bart 2.6.37.6-smp #2 SMP Sat Apr 9 23:39:07 CDT 2011 i686 Intel(R) Atom(TM) CPU D425   @ 1.80GHz GenuineIntel GNU/Linux
This is BASH 4.1 - DISPLAY on localhost:10.0
Machine Uptime  04:54:24 up 1 day, 40 min,  1 user,  load average: 0.00, 0.01, 0.05
Today is Thu Jul  7 04:54:24 EDT 2011

      July 2011     
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

... [concerning quotation marks] even if we *did* quote anybody in this
business, it probably would be gibberish.
                -- Thom McLeod