# This file is sourced by all *interactive* bash shells on startup, # including some apparently interactive shells such as scp and rcp # that can't tolerate any output. # Test for an interactive shell. There is no need to set anything # past this point for scp and rcp, and it's important to refrain from # outputting anything in those cases. if [[ $- != *i* ]] then # Shell is non-interactive. Be done now return fi DISTRO='Unknown' OS='Unknown' VERSION='Unknown' # Figure out what os/distro we are on if which uname &> /dev/null then OS=`uname` fi if [[ "$OS" == "Darwin" ]] then DISTRO="OS X" fi if [ -f /etc/lsb*release ] then eval `cat /etc/lsb*release` DISTRO=$DISTRIB_ID fi if [ -f /etc/gentoo-release ] then DISTRO="Gentoo" fi ROOTGROUP=0 groups | grep wheel &> /dev/null if [ "$OS" == "Linux" -a $? == 0 ] then ROOTGROUP=1 fi groups | grep admin &> /dev/null if [ "$OS" == "Darwin" -a $? == 0 ] then ROOTGROUP=1 fi # Source some default files for file in /etc/profile /etc/bash/bashrc /etc/profile.d/bash-completion /sw/bin/init.sh do if [ -f $file ] then source $file fi done # Functions, here so they get reset if defined from above abspath() { P=`dirname $1` if [ $P = "." ] then echo `pwd`/`basename $1` else echo $P/`basename $1` fi } append_path() { if [ -d $2 ] then if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o -z "\"\${$1##$2:*}\"" -o -z "\"\${$1##$2}\"" then eval "export $1=\$$1:$2" fi fi } prepend_path() { if [ -d $2 ] then if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o -z "\"\${$1##$2:*}\"" -o -z "\"\${$1##$2}\"" then eval "export $1=$2:\$$1" fi fi } if [ $ROOTGROUP -eq 1 ] then alias su="sudo -i" fi alias ssh="ssh -A" alias ls="ls -v -h --color=auto" alias update_bashrc='wget http://www.kormoc.com:8080/stuff/bashrc -O ~/.bashrc; source ~/.bashrc' alias update_ssh='mkdir ~/.ssh;wget http://www.kormoc.com:8080/stuff/public_key -O ~/.ssh/authorized_keys;chmod -R og-rwx ~/.ssh' alias less="less -R" alias cdlast='for entry in *; do if [ -d $entry ]; then dir=$entry; fi; done; cd $dir' alias wipesvn='for dir in `find . -name .svn`; do echo "wiping $dir"; rm -rf $dir; done' if which vim &> /dev/null then export EDITOR="vim" alias edit="vim" alias vi="vim" alias vim="vim -N" fi if [[ ${EUID} == 0 ]] then export PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' else export PS1="\[\033[0;34m\]\u@\[\033[0;32m\]\h\[\033[01;34m\]: \[\033[0;32m\]\w\[\033[0m\] > " fi export HISTCONTROL=ignoredups # Ignore a few commands export HISTIGNORE="&:ls:[bf]g:exit" export CLICOLOR=true # Add in sbin's to the path if in the wheel group if [ $ROOTGROUP -eq 1 ] then prepend_path PATH /usr/sbin prepend_path PATH /sbin fi # Add in custom paths for dir in /usr/X11R6/bin do append_path PATH $dir done for dir in /usr/lib/ccache/bin /usr/lib/distcc/bin ~/.bin do prepend_path PATH $dir done # colors for ls, etc for file in /etc/DIR_COLORS ~/.dir_colors do if [ -f $file ] then eval `dircolors -b $file` fi done file=`which komodo 2>/dev/null` if [ "$OS" == "Linux" -a -f "$file" ] then alias edit="komodo" fi # Setup ssh keys if [[ -f ~/.ssh/id_rsa ]] then if [ ! -e "$SSH_AUTH_SOCK" ] then eval `ssh-agent` > /dev/null fi if [ "$OS" == "Linux" ] then ssh-add -l &> /dev/null if [ $? -eq 1 ] then ssh-add fi fi fi # Setup xterm outputting if non-apple if [[ "$OS" != "Darwin" ]] then case $TERM in xterm*|rxvt|Eterm|eterm) export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"' ;; screen) export PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"' ;; esac fi # OSX Stuff below if [[ "$OS" == "Darwin" ]] then # Fink installed? if [ -d /sw ] then export CFLAGS="-I/sw/include" export LDFLAGS="-L/sw/lib" export CXXFLAGS=$CFLAGS export CPPFLAGS=$CXXFLAGS export ACLOCAL_FLAGS="-I /sw/share/aclocal" export PKG_CONFIG_PATH="/sw/lib/pkgconfig" export MACOSX_DEPLOYMENT_TARGET=10.4 prepend_path PATH /sw/bin if [ $ROOTGROUP -eq 1 ] then prepend_path PATH /sw/sbin fi fi # Mac Ports? if [ -d /opt/local ] then prepend_path PATH /opt/local/bin if [ $ROOTGROUP -eq 1 ] then prepend_path PATH /opt/local/sbin fi prepend_path MANPATH /opt/local/share/man export QTDIR=/opt/local/lib/qt3 fi append_path PATH /usr/libexec if [ -e /usr/bin/open-x11 ] then /usr/bin/open-x11 if [[ ! $DISPLAY ]] then export DISPLAY=":0.0" fi fi alias edit="open -a 'Komodo Edit.app'" fi export GREP_OPTIONS='' # Setup grep if grep --help | grep -- --exclude-dir= &> /dev/null then export GREP_OPTIONS='--exclude-dir=.svn '$GREP_OPTIONS else if grep --help | grep -- --exclude= &> /dev/null then export GREP_OPTIONS='--exclude=\*.svn\* '$GREP_OPTIONS fi fi # Turn on grep colorization if echo hello | grep --color=auto l &>/dev/null then export GREP_OPTIONS='--color=auto '$GREP_OPTIONS export GREP_COLOR='0;32' fi