# Erwan STIPON 21/08/2012 ################################################# # ENVIRONMENT ############################################################# declare -x HOSTNAME=`/bin/uname -n` # host name declare -x LANG=C # C Programming language declare -x VISUAL=gvim # C-xC-e shortcut graphical mode declare -x EDITOR=vim # C-xC-e shortcut command line mode declare -x BROWSER=firefox # web browser declare -x HISTSIZE=5000 # size of history declare -x HISTFILESIZE=20000 # size of history file declare -x EMAIL=erwan.stipon@sagem.com # mailto declare -x MAIL=${HOME}/.mailbox # mailBox declare -x HISTCONTROL=ignoreboth # force ignoredups and ignorespace declare -x TERM=xterm # ALIASES ################################################################# if [ -f ~/.bash_aliases ] then . ~/.bash_aliases fi alias car='cat' alias cd..='cd ..' alias grpe='grep' alias mroe='more' alias iv='vi' alias tial='tail' alias xs='cd' alias vf='cd' alias clr='clear' alias printenv='printenv | sort' alias h='history' alias vi='vim' # custom colors for ls grep etc if [ -x /usr/bin/dircolors ]; then if [ -f ~/DIRCOLORS ]; then # Custom color table eval `dircolors ~/DIRCOLORS` else eval "`dircolors -b`" # Default color table fi alias ls='ls --color=auto' alias dir='dir --color=auto' alias vdir='vdir --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi # SPECIFIC BASHRC ENV ##################################################### declare -x OS=`uname -s` # OS type declare -x SUPER_USER="FALSE" # used for root specific tasks # ANSI COLORS ############################################################# declare -x C_NORM_BLACK="\033[0;30m" # normal black declare -x C_NORM_RED="\033[0;31m" # normal red declare -x C_NORM_GREEN="\033[0;32m" # normal green declare -x C_NORM_YELLOW="\033[0;33m" # normal font yellow declare -x C_NORM_BLUE="\033[0;34m" # normal font blue declare -x C_NORM_MAGENTA="\033[0;35m" # normal font magenta declare -x C_NORM_CYAN="\033[0;36m" # normal font cyan declare -x C_NORM_WHITE="\033[0;37m" # normal font white declare -x C_BOLD_BLACK="\033[1;30m" # bold black declare -x C_BOLD_RED="\033[1;31m" # bold red declare -x C_BOLD_GREEN="\033[1;32m" # bold green declare -x C_BOLD_YELLOW="\033[1;33m" # bold yellow declare -x C_BOLD_BLUE="\033[1;34m" # bold blue declare -x C_BOLD_MAGENTA="\033[1;35m" # bold magenta declare -x C_BOLD_CYAN="\033[1;36m" # bold cyan declare -x C_BOLD_WHITE="\033[1;37m" # bold white declare -x C_BG_BLACK="\033[0;40m" # black background declare -x C_BG_RED="\033[0;41m" # red background declare -x C_BG_GREEN="\033[0;42m" # green background declare -x C_BG_YELLOW="\033[0;43m" # yellow background declare -x C_BG_BLUE="\033[0;44m" # blue background declare -x C_BG_MAGENTA="\033[0;45m" # magenta background declare -x C_BG_CYAN="\033[0;46m" # cyan background declare -x C_BG_WHITE="\033[0;47m" # white background declare -x C_NONE="\033[0m" # no colors (reset terminal) # FUNCTIONS DECLARATIONS ################################################## function Paths() { local CURRENT_PATH local CURRENT_LD_PATH local CURRENT_CDPATH local CURRENT_MANPATH unset PATH # PATH LINUX local -a PATH_LIST=( ~/bin /bin /opt/local/bin /etc/bin /usr/bin \ /etc /sbin /usr/sbin /usr/ucb /usr/X11R6/bin \ /opt/python/bin /usr/local/bin ~slprm/bin ) for CURRENT_PATH in ${PATH_LIST[@]} ; do export PATH=${PATH:+$PATH:}${CURRENT_PATH} done unset CDPATH # CD_PATH COMMON local -a CDPATH_LIST=( . $STAGING/SS_APPRENS $STAGING/SS_APPPM \ $STAGING/SS_SRVPM $STAGING/SS_APPRVT \ $STAGING/SS_APPADMINMAT $STAGING/SS_GstDos \ $REPLANCEUR $RACINE_SLPRM/.. $STAGING ) for CURRENT_CDPATH in ${CDPATH_LIST[@]} ; do export CDPATH=${CDPATH:+$CDPATH:}$CURRENT_CDPATH done unset MANPATH # MAN PATH COMMON local -a MANPATH_LIST=( /usr/man /usr/share/man /opt/SUNWspro/man \ /usr/dt/man /usr/local/man /usr/openwin/man \ /usr/local/lib/perl5/man ) \ for CURRENT_MANPATH in ${MANPATH_LIST[@]} ; do export MANPATH=${MANPATH:+$MANPATH:}$CURRENT_MANPATH done return 0 } umask 022 # user mask ulimit -c 0 # disable core dumps ulimit -n 1024 # max files by process #bind '"\e[3~": delete-char'# bind suppr to delete char set -o vi # vi-like line edditing set -o notify # async notify about background job completion trap 2 ID=`/usr/bin/id -u` if [ ${ID} == "0" ]; then SUPER_USER="TRUE" else SUPER_USER="FALSE" fi # Prompt setup HILIT=${C_BOLD_YELLOW} if [ ! -f ${HOME}/.hostname.local ] then HILIT=${C_BOLD_BLUE} # local by default .. else if [ "${DISPLAY}" != ":0.0" ] || \ [ "`cat ${HOME}/.hostname.local`" != "${HOSTNAME}" ] then HILIT=${C_NORM_RED} # distant else HILIT=${C_BOLD_BLUE} # local fi fi if [ ${SUPER_USER} == "TRUE" ]; then # user@machine[HH:MM] # ROOT: # prompt export PS1="\[${C_NORM_RED}\u${C_NONE}@${C_NORM_CYAN}\h${C_NONE}[\A] \W ${C_NORM_GREEN}#${C_NONE} \]" else # USER: $ prompt export PS1="\[${HILIT}\u${C_NONE}@${C_NORM_CYAN}\h${C_NONE}[\A] \W ${C_NORM_GREEN}>${C_NONE} \]" fi # Display setup export DISPLAY=":0.0" xhost + > /dev/null 2>&1 # ^ # bash completion if [ -f /etc/bash_completion ]; # enable programmable completion then # features (you don't need to . /etc/bash_completion # enable this, if it's already fi # enabled in /etc/bash.bashrc and # /etc/profile sources # /etc/bash.bashrc). # lesspipe if [ -x /usr/bin/lesspipe ] then # make less more friendly for eval "$(SHELL=/bin/sh lesspipe)" # non-text input files, see fi # lesspipe (1) Paths cd # -> HOME case "${-}" in *i*) ;; # shell is interactive *c*) echo ${-} ;; # shell runs a distant command * ) echo "Non interactive";; # shell is not interactive esac