# /etc/bash/bashrc
#
# 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. So make sure this doesn't display
# anything or bad things will happen !
# 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
# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control. #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize
# Enable history appending instead of overwriting. #139609
shopt -s histappend
# Change the window title of X terminals
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS. Try to use the external file
# first to take advantage of user additions. Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
if ${use_color} ; then
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi
alias grep='grep --colour=auto'
else
if [[ ${EUID} == 0 ]] ; then
# show root@ when we don't have colors
PS1='\u@\h \W \$ '
else
PS1='\u@\h \w \$ '
fi
fi
# environment variables
# make a long History
export HISTSIZE=10000000
export HISTCONTROL=ignoreboth
shopt -s histappend
# Add Macport MAN PATH, make it primary
export MANPATH=/opt/local/share/man:$MANPATH
export CVSROOT=/usr/local/cvsroot
export CVS_RSH=/usr/bin/ssh
export SVN_EDITOR="vi"
export EDITOR="mate"
# Rake Autocomplete
#complete -W "$(rake -T | awk 'NR != 1 {print $2}')" rake
#complete -W "$(cat /etc/hosts | awk '$1 != "#" {print $2}')" ssh
# make bash autocomplete with up arrow/down arrow
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
# The path is initially set to "/bin:/sbin:/usr/bin:/usr/sbin" for OSX
# PATH with Macports
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:$PATH
# ADD X11 apps to the PATH ends
export PATH=$PATH:/usr/X11R6/bin:/usr/X11/bin
# Amazaon ec2 command line tools
export JAVA_HOME='/usr/'
export EC2_HOME="/opt/local/share/ec2-api-tools"
export PATH=$PATH:$EC2_HOME/bin
# ADD Rubygems to the PATH
export PATH=/opt/local/lib/ruby/gems/1.8/bin:$PATH
# ADD Mysql to PATH
export PATH=$PATH:/opt/local/lib/mysql5/bin
# OSX Shoes Ruby Framework
export PATH=$PATH:/Applications/Shoes.app/Contents/MacOS
# Postgresql for OSX from macports
export PATH=$PATH:/opt/local/lib/postgresql83/bin
# SOme Funkie Functions
function edgie() {
ruby ~/rails/rails/railties/bin/rails $1 &&
cd $1 &&
ln -s ~/rails/rails/ vendor/rails &&
mate .
}
function mysql_start() {
mysqld_safe --defaults-file=/opt/local/etc/my.cnf &
echo "Waiting 4 seconds for mysql to load"
sleep 4
if [ -f /tmp/mysql.sock ]; then
rm -rf /tmp/mysql.sock
fi
ln -s /opt/local/var/run/mysql5/mysqld.sock /tmp/mysql.sock
}
function mysql_reload() {
mysqladmin -u root reload
}
function mysql_refresh() {
mysqladmin -u root refresh
}
function mysql_status() {
mysqladmin -u root status
}
function mysql_shutdown() {
mysqladmin -u root shutdown
}
function mysql_restart() {
mysql_shutdown
sleep 4
mysql_start
}
RUBYLIB=""
RUBYLIB=$RUBYLIB:"/opt/local/lib/ruby/site_ruby/1.8"
RUBYLIB=$RUBYLIB:"/opt/local/lib/ruby/site_ruby/1.8/i686-darwin9.2.0"
RUBYLIB=$RUBYLIB:"/opt/local/lib/ruby/1.8"
RUBYLIB=$RUBYLIB:"/opt/local/lib/ruby/1.8/i686-darwin9.2.0"
export RUBYLIB
function set_ruby19() {
export PATH=/opt/ruby-1.9/bin/:$PATH
RUBYLIB=""
RUBYLIB=$RUBYLIB:"/opt/ruby-1.9/lib/ruby/site_ruby/1.9.0/"
RUBYLIB=$RUBYLIB:"/opt/ruby-1.9/lib/ruby/site_ruby/1.9.0/i686-darwin9.2.2"
RUBYLIB=$RUBYLIB:"/opt/ruby-1.9/lib/ruby/1.9.0"
RUBYLIB=$RUBYLIB:"/opt/ruby-1.9/lib/ruby/1.9.0/i686-darwin9.2.2"
# ADD Rubygems 1.9 to the PATH
export RUBYLIB
}
function set_ruby187() {
export PATH=/opt/ruby-1.8.7/bin/:$PATH
RUBYLIB=""
RUBYLIB=$RUBYLIB:"/opt/ruby-1.8.7/lib/ruby/site_ruby/1.8/"
RUBYLIB=$RUBYLIB:"/opt/ruby-1.8.7/lib/ruby/site_ruby/1.8/i686-darwin9.2.2"
RUBYLIB=$RUBYLIB:"/opt/ruby-1.8.7/lib/ruby/1.8"
RUBYLIB=$RUBYLIB:"/opt/ruby-1.8.7/lib/ruby/1.8/i686-darwin9.2.2"
export RUBYLIB
}
function set_ruby_osx() {
export PATH=/usr/bin/:$PATH
RUBYLIB=""
RUBYLIB=$RUBYLIB:"/usr/lib/ruby/site_ruby/1.8"
RUBYLIB=$RUBYLIB:"/usr/lib/ruby/site_ruby/1.8/universal-darwin9.0"
RUBYLIB=$RUBYLIB:"/usr/lib/ruby/1.8"
RUBYLIB=$RUBYLIB:"/usr/lib/ruby/1.8/universal-darwin9.0"
export RUBYLIB
}
# Compiling code with GCC enabled for Core 2 Duo only
# needs Intel Core 2 Duo CPU
export ARCHFLAGS='-arch i386'
export CFLAGS=' -march=nocona -O2 -pipe -mtune=nocona '
# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs
if [ -f /etc/bash_completion ]; then
source /etc/bash_completion
fi
# Common Aliases
if [ -f $HOME/.bash/aliases ]; then
source $HOME/.bash/aliases
fi
# SSH Aliases
if [ -f $HOME/.bash/ssh ]; then
source $HOME/.bash/ssh
fi