Bashrc cleaned up. Local definitions are moved to a separate file.

This commit is contained in:
Vahagn Khachatryan
2016-04-08 13:40:41 -04:00
parent e683f35674
commit 3a585a6412

324
config/.bashrc Normal file → Executable file
View File

@@ -1,4 +1,4 @@
# ~/.bashrc: executed by bash(1) for non-login shells. #!/bin/bash
# ~/.bashrc skeleton # ~/.bashrc skeleton
# ~/.bashrc runs ONLY on non-login subshells! (different from ksh) # ~/.bashrc runs ONLY on non-login subshells! (different from ksh)
@@ -7,240 +7,40 @@
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#echo "BASHRC has run" #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 # Source global definitions
# #
if [ -f /etc/bashrc ]; then if [ -f /etc/bashrc ]; then
. /etc/bashrc . /etc/bashrc
else else
# are we an interactive shell? # are we an interactive shell?
if [ "$PS1" ]; then if [ "$PS1" ]; then
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"' PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
# Turn on checkwinsize # Turn on checkwinsize
shopt -s checkwinsize shopt -s checkwinsize
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi fi
if ! shopt -q login_shell ; then # We're not a login shell if ! shopt -q login_shell ; then # We're not a login shell
for i in /etc/profile.d/*.sh; do for i in /etc/profile.d/*.sh; do
if [ -r "$i" ]; then if [ -r "$i" ]; then
if [ "$PS1" ]; then if [ "$PS1" ]; then
. $i . $i
else else
. $i &>/dev/null . $i &>/dev/null
fi fi
fi fi
done done
unset i unset i
fi fi
fi fi
umask 002 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. # Find out system details.
# #
os=`uname -o` #GNU/Linux AIX Solaris os=`uname -o` #GNU/Linux AIX Solaris
cpu=`uname -p` #x86_64 powerpc sparc cpu=`uname -p` #x86_64 powerpc sparc
@@ -249,6 +49,15 @@ kversion=`uname -v`
krelease=`uname -r` krelease=`uname -r`
hostnm=`hostname` hostnm=`hostname`
#
# Tmux usually sets screen-256color which is unknown to most of systems I work
# with.
#
if [ "$TERM" == "screen-256color" ]; then
export TERM="xterm-256color"
fi
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# #
# User specific environment and startup programs # User specific environment and startup programs
# #
@@ -260,27 +69,26 @@ fi
MYSCRIPTS=$HOME/devel/scripts MYSCRIPTS=$HOME/devel/scripts
PATH=$MYLOCAL/bin:$PATH PATH=$MYLOCAL/bin:$PATH
PATH=$MYSCRIPTS/bash:$PATH PATH=$MYSCRIPTS/bash:$PATH
PATH=$MYSCRIPTS/bloomberg:$PATH
# #
# VIM # VIM
# #
#VIMDIR=/depot/vim-7.3/bin #VIMDIR=/depot/vim-7.3/bin
#VIM=${VIMDIR}/vim #VIM=${VIMDIR}/vim
#if [ "$kernel" == "Linux" ]; then #if [ "$kernel" == "Linux" ]; then
# alias vi=$VIM # alias vi=$VIM
# alias vim=$VIM # alias vim=$VIM
# alias gvim=${VIMDIR}/gvim # alias gvim=${VIMDIR}/gvim
# alias ctags="/depot/ctag-5.5.4/bin/ctags" # alias ctags="/depot/ctag-5.5.4/bin/ctags"
#fi #fi
# #
# GIT # GIT
# #
[ -f $MYSCRIPTS/bash/git-completion.bash ] && . $MYSCRIPTSE/bash/git-completion.bash [ -f $MYSCRIPTS/bash/git-completion.bash ] && . $MYSCRIPTSE/bash/git-completion.bash
# #
# GCC # GCC
# #
#if [ -e /depot/gcc-4.7.2/bin ]; then #if [ -e /depot/gcc-4.7.2/bin ]; then
# PATH=/depot/gcc-4.7.2/bin:$PATH # PATH=/depot/gcc-4.7.2/bin:$PATH
@@ -294,18 +102,18 @@ PATH=$MYSCRIPTS/bloomberg:$PATH
#fi #fi
# #
# GDB # GDB
# #
#prepath /depot/gdb-7.5.1/bin #prepath /depot/gdb-7.5.1/bin
# #
# VTune Amplifier # VTune Amplifier
# #
#export INTEL_LICENSE_FILE=28518@us01-lic10:28518@us01-lic11:28518@us01-lic12:28518@tyndall #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 #alias vtune=/depot/vtune_amplifier_xe_2013_update5/bin64/amplxe-gui
# #
# PURIFY and all. # PURIFY and all.
# #
#postpath /depot/coverity/swat/bin #postpath /depot/coverity/swat/bin
#export RSU_TEMPLATE2_INI=/depot/pure/templates2.ini #export RSU_TEMPLATE2_INI=/depot/pure/templates2.ini
@@ -319,42 +127,34 @@ PATH=$MYSCRIPTS/bloomberg:$PATH
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# #
# BLOOMBERG and TOMS # Run local settings.
# #
[ -f $PWD/.bashrc.local ] && . $PWD/.bashrc.local
# 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 # set alias
# #
alias ll='ls -la --color=tty' if [ $kernel == AIX ]; then
alias cd='pushd >/dev/null' alias l='ls -a'
alias bd='popd' alias ls='ls -a'
alias bb='pushd $HOME/devel/bb >/dev/null' alias ll='ls -la'
alias cgrep="grep --include \*.cpp --include \*.h --include \*.c --color=auto" alias pd='pushd >/dev/null'
#complete -f --X '!*.mk' plink 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 # Make sure to export PATH
# #
export PATH export PATH
#export LM_LICENSE_FILE #export LM_LICENSE_FILE
export HISTFILESIZE=5000 # Store 5000 commands in history export HISTFILESIZE=5000 # Store 5000 commands in history
export HISTCONTROL=ignoredups # Don't put duplicate lines in the history. export HISTCONTROL=ignoredups # Don't put duplicate lines in the history.