AzizLight /.bash_profile

Most of the content is taken from Shell-fu.org and dotfiles.org I use the same functions on OS X and Ubuntu (except the one that opens man pages in Preview.app)
# =============
# = Variables =
# =============

export PAGER="less"
export EDITOR="mate -w"
export VISUAL=$EDITOR

# These two are needed in order for MacPorts to work
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH

# Customized prompt
# PS1="\W $ "
export PS1="\[\e[1;32m\]"`whoami`"\[\e[m\]\[\e[0;36m\]@\[\e[m\]\[\e[1;31m\]"`hostname`"\[\e[m\]\[\e[0;36m\]:\[\e[m\]\[\e[1;33m\]\w\[\e[m\]"`echo "\n\r"`"\[\e[1;37m\] $ \[\e[m\]"


# auto-completion is not case sensitive anymore
set completion-ignore-case On

# Tab completion for sudo
complete -cf sudo

# ===========
# = Aliases =
# ===========

# I copied all my aliases in ~/.bash_aliases
if [ -f ~/.bash_aliases ]; then
	. ~/.bash_aliases
fi

# =============
# = Functions =
# =============

## Archives
# Extract about anything
extract () 
{
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)   tar xvjf $1        ;;
            *.tar.gz)    tar xvzf $1     ;;
            *.bz2)       bunzip2 $1       ;;
            *.rar)       unrar x $1     ;;
            *.gz)        gunzip $1     ;;
            *.tar)       tar xvf $1        ;;
            *.tbz2)      tar xvjf $1      ;;
            *.tgz)       tar xvzf $1       ;;
            *.zip)       unzip $1     ;;
            *.Z)         uncompress $1  ;;
            *.7z)        7z x $1    ;;
            *)           echo "'$1' cannot be extracted via >extract<" ;;
        esac
    else
        echo "'$1' is not a valid file"
    fi
}

# List the most recent files in a directory
lsnew()
{
	ls -lt ${1+"$@"} | head -20;
}

# Open a manpage in Preview, which can be saved to PDF
pman()
{
   man -t "${1}" | open -f -a /Applications/Preview.app
}