Hello all,
The code listed below is a copy of my .bashrc file that I use on my HP compaq 6715b laptop I use Suse version 11.0 I have no need to upgrade to version 11.1 for now.
I have been working on my .Bashrc file for some time now and as you can see it is very long.
Is there any way to stream line or optimize this file?
fell free to rip it apart use for your own needs. if you have any cool items (alias or functions) please share them.
Code begins--------->
#######################################################
# your name.bashrc file
# Your web site
# Your Blog site
#
# Last Modified 04-25-2009
# Running on OpenSuSE 11
#######################################################
# EXPORTS
#######################################################
PATH=$PATH:/usr/lib/festival/ ;export PATH
export PS1="[\[\033[1;34m\w\[\033[0m]\n[\t \u]$ "
export EDITOR=/usr/bin/nano
# History Time Format ='%F %T'
HISTTIMEFORMAT='%m-%d %H:%M:%S | '
export HISTSIZE=100000000
export HISTFILESIZE=100000000 # the bash history should save 100000000 commands
export HISTCONTROL=ignoredups #don't put duplicate lines in the history.
alias hist='history | grep $1' #Requires one input
# Define a few Color's
#######################################################
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
# ALIAS'S OF ALL TYPES SHAPES AND FORMS
#######################################################
# Alias's to control hardware
alias cdo='eject /dev/cdrecorder'
alias cdc='eject -t /dev/cdrecorder'
alias dvdo='eject /dev/dvd'
alias dvdc='eject -t /dev/dvd'
alias scan='scanimage -L'
alias playw='for i in *.wav; do play $i; done'
alias playo='for i in *.ogg; do play $i; done'
alias playm='for i in *.mp3; do play $i; done'
alias copydisk='dd if=/dev/dvd of=/dev/cdrecorder' # Copies bit by bit from dvd to cdrecorder drives.
alias dvdrip='vobcopy -i /dev/dvd/ -o ~/DVDs/ -l'
# Alias's to modified commands
#######################################################
alias ps='ps auxf'
alias home='cd ~'
alias pg='ps aux | grep'* #requires an argument
alias mountedinfo='df -hT'
alias ping='ping -c 10'
alias openports='netstat -nape --inet'
alias ns='netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail +2'
alias du1='du -h --max-depth=1'
alias da='date "+%Y-%m-%d %A*** %T %Z"'
alias ebrc='nano ~/.bashrc'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p'
alias reload="source ~/.bashrc" # reload bashrc after it is modified
alias packup='/bin/tar -czvf' # Compress a file in tar format
alias unpack='/bin/tar -xzvpf' # Uncompress a a Tar file
alias contents='/bin/tar -tzf' # Can View the contents of a Tar file
alias mktd='tdir=`mktemp -d` && cd $tdir' # make a temp dir, then immediately cd into it
# Alias to multiple ls commands
#######################################################
alias la='ls -Al'************** # show hidden files
alias ls='ls -aF --color=always' # add colors and file type extensions
alias lx='ls -lXB'************* # sort by extension
alias lk='ls -lSr'************* # sort by size
alias lr='ls -lR'************** # recursive ls
alias lt='ls -ltr'************* # sort by date
alias lm='ls -al |more'******** # pipe through 'more'
alias directory='ls --color=auto --format=long' # enable color support of ls and also add handy aliases
# Alias chmod commands
#######################################################
alias mx='chmod a+x'
alias 000='chmod 000'
alias 644='chmod 644'
alias 755='chmod 755'
# Alias Shortcuts to graphical programs.
#######################################################
alias kwrite='kwrite 2>/dev/null &'
alias firefox='firefox 2>/dev/null &'
alias kate='kate 2>/dev/null &'
alias suk='kdesu konqueror 2>/dev/null &'
# Alias for xterm and aterm
#######################################################
alias term='xterm -bg AntiqueWhite -fg Black &'
alias termb='xterm -bg AntiqueWhite -fg NavyBlue &'
alias termg='xterm -bg AntiqueWhite -fg OliveDrab &'
alias termr='xterm -bg AntiqueWhite -fg DarkRed &'
alias aterm='xterm -ls -fg gray -bg black'
alias xtop='xterm -fn 6x13 -bg LightSlateGray -fg black -e top &'
alias xsu='xterm -fn 7x14 -bg DarkOrange4 -fg white -e su &'
# Alias for lynx web browser and internet
#######################################################
alias bbc='lynx -term=vt100
http://news.bbc.co.uk/text_only.stm'
alias nytimes='lynx -term=vt100
http://nytimes.com'
alias myip="curl www.whatismyip.org"
alias updates='sudo zypper list-updates' #checks system for updates
# SPECIAL FUNCTIONS
#######################################################
netinfo ()
{
echo "--------------- Network Information ---------------"
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
/sbin/ifconfig | awk /'inet addr/ {print $4}'
/sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
echo "---------------------------------------------------"
}
spin ()
{
echo -ne "${RED}\b#"
echo -ne "${WHITE}\b%"
echo -ne "${BLUE}\b%"
sleep 1.60
echo -ne "${RED}\b#${NC}"
}
scpsend ()
{
scp -P PORTNUMBERHERE "$@"
USERNAME@YOURWEBSITE.com:/var/www/html/pathtodirectoryonremoteserver/;
}
# Weather by us zip code - Can be called two ways # weather 50315 # weather "Des Moines"
weather ()
{
declare -a WEATHERARRAY
WEATHERARRAY=( `lynx -dump "http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+${1}&btnG=Search" | grep -A 5 -m 1 "Weather for"`)
echo ${WEATHERARRAY[@]}
}
# Stock prices - can be called two ways. # stock novl (this shows stock pricing) #stock "novell" (this way shows stock symbol for novell)
stock ()
{
stockname=`lynx -dump http://finance.yahoo.com/q?s=${1} | grep -i ":${1})" | sed -e 's/Delayed.*$//'`
stockadvise="${stockname} - delayed quote."
declare -a STOCKINFO
STOCKINFO=(` lynx -dump http://finance.yahoo.com/q?s=${1} | egrep -i "Last Trade:|Change:|52wk Range:"`)
stockdata=`echo ${STOCKINFO[@]}`
if [[ ${#stockname} != 0 ]] ;then
echo "${stockadvise}"
echo "${stockdata}"
else
stockname2=${1}
lookupsymbol=`lynx -dump -nolist http://finance.yahoo.com/lookup?s="${1}" | grep -A 1 -m 1 "Portfolio" | grep -v "Portfolio" | sed 's/\(.*\)Add/\1 /'`
if [[ ${#lookupsymbol} != 0 ]] ;then
echo "${lookupsymbol}"
else
echo "Sorry $USER, I can not find ${1}."
fi
fi
}
#Translate a Word - USAGE: translate house spanish # See dictionary.com for available languages (there are many).
translate ()
{
TRANSLATED=`lynx -dump "http://dictionary.reference.com/browse/${1}" | grep -i -m 1 -w "${2}:" | sed 's/^[ \t]*//;s/[ \t]*$//'`
if [[ ${#TRANSLATED} != 0 ]] ;then
echo "\"${1}\" in ${TRANSLATED}"
else
echo "Sorry, I can not translate \"${1}\" to ${2}"
fi
}
# Define a word - USAGE: define dog
define ()
{
lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}&btnG=Google+Search" | grep -m 3 -w "*" | sed 's/;/ -/g' | cut -d- -f1 > /tmp/templookup.txt
if [[ -s /tmp/templookup.txt ]] ;then
until ! read response
do
echo "${response}"
done < /tmp/templookup.txt
else
echo "Sorry $USER, I can't find the term \"${1} \""
fi
rm -f /tmp/templookup.txt
}
# lazy man extract - example: ex tarball.tar
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjfv $1 ;;
*.tar.gz) tar xzfv $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xfv $1 ;;
*.tbz2) tar xjfv $1 ;;
*.tgz) tar xzfv $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 - a little clock that appeares in the terminal window.
# Usage: clock.
clock ()
{
while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done
}
# WELCOME SCREEN
#######################################################
clear
for i in `seq 40 40` ; do spin; done ;echo -ne "${WHITE}JADA ${NC}"; for i in `seq 40 40` ; do spin; done ;echo "";
echo -e ${LIGHTBLUE}`cat /etc/SuSE-release` ;
echo -e "Kernel Information: " `uname -smr`;
echo -e ${LIGHTBLUE}`bash --version`;echo ""
echo -ne "Hello $USER today is "; date
echo -e "${WHITE}"; cal ; echo "";
echo -ne "${CYAN}";netinfo;
mountedinfo ; echo ""
echo -ne "${LIGHTBLUE}Uptime is ";uptime | awk /'up/ {print $3,$4}'
for i in `seq 40 40` ; do spin; done ;echo -ne "${WHITE}http://www.yoursite.com/${NC}"; for i in `seq 40 40` ; do spin; done ;echo "";
echo ""; echo ""
###########################################################
Code Ends------------------>