#!/usr/bin/env bash

# Remove zsh completion dump
rm ~/.zcompdump

# Remove vim config directory
rm -rf ~/.vim-backup
mv ~/.vim ~/.vim-backup
mkdir -p ~/.vim/{autoload,bundle,colors,doc,ftplugin,plugin,spell,syntax}

# Install oh-my-zsh
rm -rf ~/.oh-my-zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh

touch ~/.zshrc-local


pip install --upgrade --user jedi
pip install --upgrade --user git+git://github.com/Lokaltog/powerline

# Copy the graphical part if needed
if [ "$1" == '--graphic' ]
then
    rsync -av graphic/ ~/
    fc-cache -vf ~/.fonts
fi

# Copy the common part
rsync -av common/ ~/

# Adjust the tmux conf
sed -i "s/REPLACEMEWITHFIRSTLETTEROFHOSTNAME/`expr substr \`hostname\` 1 1`/g" ~/.tmux.conf

######### VIM Config ###########

# Install pathogen

mkdir ~/.vim/autoload
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim

# Install jedi plugin for vim
rm -rf ~/.vim/bundle/jedi
git clone https://github.com/davidhalter/jedi-vim.git ~/.vim/bundle/jedi

# Install nerdtree for vim
rm -rf ~/.vim/bundle/nerdtree
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree

# Install xmledit for vim
rm -rf ~/.vim/bundle/xmledit
git clone https://github.com/sukima/xmledit.git ~/.vim/bundle/xmledit
pushd ~/.vim/bundle/xmledit
make install
popd

# Install syntastic plugin
rm -rf ~/.vim/bundle/syntastic
git clone --recursive https://github.com/scrooloose/syntastic.git ~/.vim/bundle/syntastic

# Install autoclose plugin
rm -rf ~/.vim/bundle/autoclose
git clone https://github.com/Townk/vim-autoclose.git ~/.vim/bundle/autoclose

# Install tagbar plugin
rm -rf ~/.vim/bundle/tagbar
git clone https://github.com/majutsushi/tagbar ~/.vim/bundle/tagbar

# Install vcscommand plugin
rm -rf ~/.vim/bundle/vcscommand
git clone https://github.com/vim-scripts/vcscommand.vim.git ~/.vim/bundle/vcscommand

# Remove easytag plugin
rm -rf ~/.vim/bundle/easytag
#git clone https://github.com/vim-scripts/easytags.vim.git ~/.vim/bundle/easytag

# Install closetag plugin
rm -rf ~/.vim/bundle/closetag
git clone https://github.com/vim-scripts/closetag.vim.git ~/.vim/bundle/closetag

# Install css3 syntax
rm -rf ~/.vim/bundle/css3-mod
git clone https://github.com/vim-scripts/css3-mod.git ~/.vim/bundle/css3-mod

# Install less syntax
rm -rf ~/.vim/bundle/vim-less
git clone https://github.com/groenewege/vim-less.git ~/.vim/bundle/vim-less

# Install grep plugin
rm -rf ~/.vim/bundle/grep
git clone https://github.com/vim-scripts/grep.vim.git ~/.vim/bundle/grep

# Install vimwiki
rm -rf ~/.vim/bundle/vimwiki
hg clone https://code.google.com/p/vimwiki/src ~/.vim/bundle/vimwiki

# Install notes plugin
rm -rf ~/.vim/bundle/misc
git clone https://github.com/xolox/vim-misc.git ~/.vim/bundle/misc

rm -rf ~/.vim/bundle/notes
git clone https://github.com/xolox/vim-notes.git ~/.vim/bundle/notes

# Install better highlighting for Python
rm -rf ~/.vim/bundle/python-syntax
git clone https://github.com/hdima/python-syntax.git ~/.vim/bundle/python-syntax
