General bashrc.

This commit is contained in:
2015-12-10 22:40:45 +00:00
parent 7f8f4b8688
commit d9d53bba21

360
config/.bashrc Normal file
View File

@@ -0,0 +1,360 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# ~/.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"
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -lAF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Source global definitions
#
if [ -f /etc/bashrc ]; then
. /etc/bashrc
else
# 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
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
#
#alias dirs='dirs -v'
#alias ack='ack --ignore-file=ext:d,dd'
#
#alias dirtree="ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' "
#alias currgit='cd /bb/mbig/mbig1205/devgit/s_tktapi2/src; echo -e "I am here $(pwd)"'
#alias tktapi='cd /bb/mbig/mbig1205/devgit/tktapi/src; echo -e "I am here $(pwd) \n $(ls)"'
#alias bastest='/bbsrc/abin/basclient'
#alias bas_codegen='/bb/shared/bin/bas_codegen.pl'
#alias metasymfind="cat - | awk '{ print \$1 }' | xargs symfind | awk 'BEGIN{FS=\"[\"} { print \$1 }' | sort | uniq | tr '\n' ' ' | sed -e 's/\(\b\S\)/-l\1/g' && echo \"\""
#
#alias git-robo='ssh devgit svnsync $(git remote -v | grep "(fetch)" | cut -d ":" -f2 | cut -d "(" -f1); git fetch origin; git pull; git merge robo/trunk; read -p "!!!!! PUSH the merged version back !!!!! ? [Y] / Ctrl+C to stop"; git push'
#alias intuorcreate=/bbsrc/internal/isystest/uorcreate/intuorcreate
#
#
#export EDITOR=/opt/swt/bin/nedit
#export TERM=xterm
#
#export BIGHOME=/bb/mbig/mbig1205
#export PLINK_PARALLEL_BUILD=true
#export EDITOR=/opt/swt/bin/nedit
#export PAGER=less
#export GROUP=trading-systems-group
#export mysvn="svn+ssh://devsvn"
#export myrobosvn="svn+ssh://devsvn/robo/branches/trunk"
#export PATH=/opt/swt/bin:~/bin:/bb/util/common/studio12/SUNWspro/bin:${PATH}
#export DEVGIT=${BIGHOME}/devgit
#export VISUAL=/opt/swt/bin/nedit
#export MAIL=/usr/mail/${LOGNAME:?}
#
#codegrep() {
# if [[ $# -eq 0 ]]
# then
# echo "Usage: codegrep <pattern> "
# else
# grep -nT --colour \
# --exclude=tags \
# --exclude=*.o \
# --exclude=*.so \
# --exclude=*.tsk \
# --exclude=*.d \
# --exclude=*.dd \
# "$1" *
# fi
#}
#
##ssh() {
# #echo "wut"
# #[[ -n "$INSCREEN" ]] && TERM=screen-256color
# #env ssh -t $*
# #$SCREEN_TITLE_CMD
##}
#
#sshcd() {
# if [[ $# -lt 1 ]]
# then
# echo "Usage: sshcd <server> [<path>]"
# else
# ssh -t $LOGNAME@$1 "export SSHCDPATH=${path:-$(pwd)}; exec $BASH --login "
# fi
#}
#
#biggest() {
# dir=${1:-.}
# find $dir -type f -exec du -a {} \+ | sort -rn
#}
#
## Screen variables
#function last2dirs {
# pwd | awk -F\/ '{print $(NF-1),$(NF)}' | sed 's# #/#'
#}
#
##screen specific functionality
##if [[ -n ${STY} ]]
##then
# PROMPT_COMMAND='echo -ne "\033k${HOSTNAME} $(last2dirs)\033\\";
# history -a;'
##fi
#
#function dupscreen {
# screen bash -c "export SSHCDPATH=$PWD && exec $SHELL --login"
#}
#
#if [ -n "$BBENV" ] && [[ -f ~/bin/hijackEOD.sh ]]
#then
# source `which hijackEOD.sh`
#fi
#
#
#
# Don't source the rest twice.
#
#if [ "$BASHRC_VAHAGNK_DONT_SOURCE_THIS_FILE_TWICE" == "true" ]; then
# return
#fi
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# 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`
#
# 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/bash:$PATH
PATH=$MYSCRIPTS/bloomberg:$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"
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# BLOOMBERG and TOMS
#
# if chimera generated aliases exist, pull them into the current ENV
[ -f ~/.bbalias ] && . ~/.bbalias
export BB=$HOME/devel/bb
export DEVGIT=$BB/devgit
PATH=$PATH:$BB/scripts
getpw() { # BOX
if [[ $# -ne 1 ]]; then
echo "Usage: getpw <machine>"
else
local BOX="$1"
local BIN="/bb/bin/getprdwin"
$BIN -u op1 -i -s $BOX -d "op1 for $USER on $BOX"
fi
}
alias create_tags='/opt/swt/bin/ctags -R --verbose --exclude=.git --exclude=.doxygen --exclude="*.o" --exclude="llcalc*"'
#
# set alias
#
alias ll='ls -la --color=tty'
alias cd='pushd >/dev/null'
alias bd='popd'
alias bb='pushd $HOME/devel/bb >/dev/null'
alias cgrep="grep --include \*.cpp --include \*.h --include \*.c --color=auto"
#complete -f --X '!*.mk' plink
#
# 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.