Sample bash profile

This a my sample .bash_profile

#########################
#Various Edits:
#########################

#bash remembers the last 5000 commands
export HISTFILESIZE=5000

# 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

#This changes what the terminal displays before the cursor
export PS1='\[\033[1;33m\]\u\[\033[1;37m\]@\[\033[1;32m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]'
#export PS1="${BLUE}(${RED}\w${BLUE}) ${NORMAL}\h ${RED}\$ ${NORMAL}"


#sur 2 lignes
#export PS1="\n[$?]\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]($SHLVL:\!)\n\[\033[0m\]\$ "
#export PS1="\n\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]\n$ \e[0m"


# Sample Command using color: echo -e "${CYAN}This is BASH
#${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}\n"

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi

# enable programmable completion features
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# Alias's to modified commands, the fun part
alias home='cd ~'
alias ping='ping -c 5'
alias openports='netstat -nape --inet'
alias ns='netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail +2'
alias la='ls -Al'               # show hidden files
alias ls='ls -aF --color=auto' # add colors and file type extensions
alias lx='ls -lXB'              # sort by extension
alias lk='ls -lSr'              # sort by size
alias lc='ls -lcr'      # sort by change time
alias lu='ls -lur'      # sort by access time
alias lr='ls -lR'               # recursive ls
alias lt='ls -ltr'              # sort by date
alias lm='ls -al |more'         # pipe through 'more'
alias grep='grep --color=auto'
alias cd1="cd .."
alias cd2="cd ../.."
alias cd3="cd ../../.."
alias cd4="cd ../../../.."
alias cd5="cd ../../../../.."

#List cron jobs (enabled and not enabled)
alias lscron="ls /etc/cron*" # list cron jobs 
# Show mac addresses
alias mac="ifconfig -a| grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'"  

# View programs using an internet connection
alias ports="lsof -i -n -P"        

# View only established sockets
alias estab="ss -p | grep STA"        

# View open ports
alias openports="netstat -nape --inet"

# Lists all listening ports together with the PID of the associated process
alias netpid="netstat -tlnp"        

# View only the process name using an internet connection   
alias appson="netstat -lantp | grep -i stab | awk -F/ '{print $2}' | sort | uniq"   

 # View network device info
alias network="sudo lshw -C network"   

# View DNS numbers
alias dns="cat /etc/resolv.conf"    

# List your device's transfer info (you may need to change your device, and you must have tcptrack installed)
alias tcptrack="sudo tcptrack -i wlan0"    

# NOTE: I've modified netstat to not require sudo. It is much easier to use it with conky and,
# for that matter, from the shell. You must add 'sudo' if you want the netstat aliases to function
# propperly without modifying the permissions.  The same goes for the hddtemp alias.


# Record the desktop (saving to /tmp/out.mpg, which may be changed to whatever)
# This can be quite cpu intensive, slower boxes be wary...
alias record="ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg"


#update and upgrade in one command
alias upgrade='sudo apt-get update && sudo apt-get -y upgrade'

# NOTES
#######################################################
# To temporarily bypass an alias, we precede the command with a \
# eg. the ls command is aliased, but to use the normal ls command you would
# type \ls
#######################################################


#export JAVA_HOME=/usr/lib/jvm/java-7-oracle/
#export PATH=$JAVA_HOME/bin:$PATH

export CEP_HOME=/u01/cep111163_home
export CEP_SAMPLES=$CEP_HOME/ocep_11.1/samples/

export  JRRT_HOME=/u01/cep111163_home/jrockit_160_29/jre
export  PATH=$JRRT_HOME/bin:$PATH

export JAVA_HOME=$JRRT_HOME
export PATH=$JAVA_HOME/bin:$PATH

alias mntdriveA='sudo mount -t cifs //<ip>/a /mnt/driveA -o user=Chenda'
alias mntdriveB='sudo mount -t cifs //<ip>/b /mnt/driveB -o user=Chenda'
alias mntbackup='sudo mount -t cifs //<ip>/backups /mnt/backup -o user=admin,rw,iocharset=utf8,file_mode=0777,dir_mode=0777'
alias mntu01='sudo mount -t nfs <ip>:/raid0/data/u01 /mnt/u01/ -o async'

_findjar() 
{
  if [ $# -ne 2 ]
  then
    echo "Usage: $0 <path> <class to search>"
  else    
    echo " argument=" $1 $2
    find $1 -name "*.jar" | xargs -tn1 jar tvf | grep --color $2
  fi  
}

alias findjar=_findjar


Advertisements

About Chenda Mok

19 years of hands on experience in software design and development with emphasis on Enterprise Application Integration (EAI), Services Oriented Architecture (SOA) and Identity Management (IDM) solutions. I’m a software engineer, member of the professional service delivery team working for Salesforce. Prior to this, I worked for Oracle as Solution Architect, through SeeBeyond(06/2005), then SUN’s acquisition (04/2009). After my master’s degree in computer science in 1997; I always delivered consulting on architecture, design, implementation on integration’s field. I’m interested in architecture using EAI/SOA/IDM/BPM/Cloud technologies, software development and Java’s related technologies. I may blog about my work/activities at Salesforce, but I do not speak for my employer, past, present or future.
This entry was posted in script. Bookmark the permalink.