Files
scripts/config/.bashrc
2016-06-03 13:45:22 -04:00

240 lines
6.1 KiB
Bash
Executable File

#!/bin/bash
# ~/.bashrc skeleton
# ~/.bashrc runs ONLY on non-login subshells! (different from ksh)
# add lines here very carefully as this may execute when you don't i
# expect them to
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#echo "BASHRC has run"
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Source global definitions
#
if [ -f /etc/bashrc ]; then
. /etc/bashrc
else
if ! shopt -q login_shell ; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then
if [ "$PS1" ]; then
. $i
else
. $i &>/dev/null
fi
fi
done
unset i
fi
fi
umask 002
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Find out system details.
#
os=`uname -o` #GNU/Linux AIX Solaris
cpu=`uname -p` #x86_64 powerpc sparc
kernel=`uname -s` #Linux AIX SunOS
kversion=`uname -v`
krelease=`uname -r`
hostnm=`hostname`
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Terminal colors.
#
if [[ $- == *i* ]]; then
#
# If there is no terminal info in the system for current terminal but there is
# one in local terminfo then use it.
#
/bin/tput -T $TERM longname 2>/dev/null >/dev/null
if [[ $? -ne 0 && -f $HOME/.terminfo/$kernel/${TERM:0:1}/$TERM ]]; then
export TERMINFO=$HOME/.terminfo/$kernel;
fi
###
# Colors
###
# reset terminal colors
c_reset="$(tput sgr0)"
# regular foreground
crf_red=$(tput setaf 1)
crf_green=$(tput setaf 2)
crf_orange=$(tput setaf 3)
crf_blue=$(tput setaf 4)
crf_pink=$(tput setaf 5)
crf_cyan=$(tput setaf 6)
crf_white=$(tput setaf 7)
# bold foreground
cbf_red=$(tput bold; tput setaf 1)
cbf_green=$(tput bold; tput setaf 2)
cbf_orange=$(tput bold; tput setaf 3)
cbf_blue=$(tput bold; tput setaf 4)
cbf_pink=$(tput bold; tput setaf 5)
cbf_cyan=$(tput bold; tput setaf 6)
cbf_white=$(tput bold; tput setaf 7)
#
# Load better colors.
#
if [ -f ~/.dir_colors ]; then
eval $(dircolors ~/.dir_colors)
fi
fi
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Prompt.
#
if [[ "$PS1" ]]; then
export PROMPT_COMMAND=__prompt_command
function __prompt_command()
{
local es=$?
if [ $es -eq 0 ]; then
local exit_code_color=$crf_green
else
local exit_code_color=$crf_red
fi
local git_branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null | tr -d ' ')
local svn_rev=$(svn info . 2> /dev/null | awk -F ':' '/Revision:/ { print $2 }')
# PS1="$cbf_blue[$exit_code_color\#$cbf_blue]" # command counter
PS1="$cbf_blue[$cbf_blue$?$cbf_blue]\n" # command counter
# PS1+=" "
PS1+="$cbf_white\u$crf_blue@$cbf_white\h$cbf_white" # username@host
# PS1+=":"
# PS1+="$crf_green\w" # working dir
if [ -n "$git_branch" ]; then
PS1+=" "
PS1+="$cbf_blue[${cbf_white}$cbf_orange$git_branch$cbf_blue]"
fi
if [ -n "$svn_rev" ]; then
PS1+=" "
PS1+="$cbf_blue[${cbf_white}$cbf_orange$svn_rev$cbf_blue]"
fi
PS1+=">"
# PS1+="$c_reset\n"
}
# are we an interactive shell?
# if [ "$PS1" ]; then
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
# # Turn on checkwinsize
# shopt -s checkwinsize
# [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
# fi
fi
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# User specific environment and startup programs
#
if [ $kernel == Linux ]; then
MYLOCAL=$HOME/local-lnx
elif [ $kernel == SunOS ]; then
MYLOCAL=$HOME/local-sun
fi
MYSCRIPTS=$HOME/devel/scripts
PATH=$MYLOCAL/bin:$PATH
PATH=$MYSCRIPTS/bin:$PATH
#
# VIM
#
#VIMDIR=/depot/vim-7.3/bin
#VIM=${VIMDIR}/vim
#if [ "$kernel" == "Linux" ]; then
# alias vi=$VIM
# alias vim=$VIM
# alias gvim=${VIMDIR}/gvim
# alias ctags="/depot/ctag-5.5.4/bin/ctags"
#fi
#
# GIT
#
[ -f $MYSCRIPTS/bash/git-completion.bash ] && . $MYSCRIPTSE/bash/git-completion.bash
#
# GCC
#
#if [ -e /depot/gcc-4.7.2/bin ]; then
# PATH=/depot/gcc-4.7.2/bin:$PATH
# LD_LIBRARY_PATH=/depot/gcc-4.7.2/lib64:$LD_LIBRARY_PATH
#elif [ -e /depot/gcc-4.7.0/bin ]; then
# PATH=/depot/gcc-4.7.0/bin:$PATH
# LD_LIBRARY_PATH=/depot/gcc-4.7.0/lib64:$LD_LIBRARY_PATH
#elif [ -e /depot/gcc-4.5.2/bin ]; then
# PATH=/depot/gcc-4.5.2/bin:$PATH
# LD_LIBRARY_PATH=/depot/gcc-4.5.2/lib64:$LD_LIBRARY_PATH
#fi
#
# GDB
#
#prepath /depot/gdb-7.5.1/bin
#
# VTune Amplifier
#
#export INTEL_LICENSE_FILE=28518@us01-lic10:28518@us01-lic11:28518@us01-lic12:28518@tyndall
#alias vtune=/depot/vtune_amplifier_xe_2013_update5/bin64/amplxe-gui
#
# PURIFY and all.
#
#postpath /depot/coverity/swat/bin
#export RSU_TEMPLATE2_INI=/depot/pure/templates2.ini
#export RSU_LICENSE_MAP=/depot/pure/PurifyPlus_License_Map
#export PURECOVOPTIONS="-force-rebuild=no -log-file=./%v.%p.log -counts-file=./%v.%p.pcv -windows=no"
#export PUREOPTIONS="-force-rebuild=no -always-use-cache-dir=yes -cache-dir=$HOME/tmp/pure_cache"
#export QUANTIFYOPTIONS="-force-rebuild=no -always-use-cache-dir=yes -cache-dir=$HOME/tmp/pure_cache"
#export LD_LIBRARY_PATH=$HOME/prj/fw/rmain/3pty/qt/4.7.2/amd64/lib:$LD_LIBRARY_PATH
#alias purecov="/depot/swe/a2007.12/bin/purecov"
#alias quantify"/depot/swe/a2007.12/bin/quantify"
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Run local settings.
#
[ -f $PWD/.bashrc.local ] && . $PWD/.bashrc.local
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# set alias
#
if [ $kernel == AIX ]; then
alias l='ls -a'
alias ls='ls -a'
alias ll='ls -la'
alias pd='pushd >/dev/null'
alias bd='popd'
else
alias l='ls -a --color=tty'
alias ls='ls -a --color=tty'
alias ll='ls -la --color=tty'
alias pd='pushd >/dev/null'
alias bd='popd'
fi
alias cgrep="grep --include \*.cpp --include \*.h --include \*.c"
#
# Make sure to export PATH
#
export PATH
#export LM_LICENSE_FILE
export HISTFILESIZE=5000 # Store 5000 commands in history
export HISTCONTROL=ignoredups # Don't put duplicate lines in the history.