#!/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` #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` # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Bash history # # 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=5000 # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize set -o vi # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # Set command prompt [ -x ~/devel/scripts/config/.profile.prompt ] && source ~/devel/scripts/config/.profile.prompt # [ -x ${MYDIR}/.profile.dircolor ] && source ${MYDIR}/.profile.dircolor # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # User specific environment and startup programs # if [ -e $HOME/bin ]; then export PATH=$HOME/bin:$PATH fi MYSCRIPTS=$HOME/devel/scripts if [ -e $MYSCRIPTS/bin ]; then export PATH=$MYSCRIPTS/bin:$PATH fi # # VIM # export EDITOR=vim export LESS=-R # # 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 # # GIT # [ -f $MYSCRIPTS/bash/git-completion.bash ] && . $MYSCRIPTSE/bash/git-completion.bash # # colored GCC warnings and errors # export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Aliases # if [ $kernel == "Darwin" ]; then alias ls='ls -a' alias ll='ls -la' alias pd='pushd >/dev/null' alias bd='popd' else alias ls='ls -a --color=auto' alias ll='ls -la --color=auto' alias pd='pushd >/dev/null' alias bd='popd' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi function cgrep() { if [[ $# -eq 0 ]] then echo "Usage: codegrep " else grep -nR --colour \ --include=\*.cpp \ --include=\*.c \ --include=\*.hpp \ --include=\*.h \ --include=\*.inc \ --include=\*.php \ --include=\*.py \ --include=\*.sh \ --exclude-dir=.git \ --exclude-dir=.svn \ --exclude-dir=llcalc* \ --exclude-dir=00* \ "$1" . fi } function create_tags() { #Bloomberg if [ -e /opt/swt/bin/ctags ]; then CTAGS=/opt/swt/bin/ctags else CTAGS=ctags fi CTAGS_OPT='--recurse=yes ' CTAGS_OPT+='--verbose ' CTAGS_OPT+='--totals=yes ' CTAGS_OPT+='--tag-relative=yes ' CTAGS_DIR_CFG='.ctags_dir' CTAGS_ROOT="$PWD" if [ ! -f $PWD/$CTAGS_DIR_CFG ]; then GIT_ROOT=$(git top pwd) if [ -f $GIT_ROOT/$CTAGS_DIR_CFG ]; then CTAGS_ROOT="$GIT_ROOT" fi fi if [ -f $CTAGS_ROOT/$CTAGS_DIR_CFG ]; then CTAGS_SRC="-L $CTAGS_ROOT/$CTAGS_DIR" else CTAGS_SRC="$@" fi cd $CTAGS_ROOT $CTAGS $CTAGS_OPT $CTAGS_SRC cd - } # Add an "alert" alias for long running commands. Use like so: # sleep 10; alert alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= # # Run local settings. # [ -x $HOME/.bashrc.local ] && . $HOME/.bashrc.local # # Clean error level. # [ 1 ]